﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using System.Data.SqlClient;
using nspLable.Manage;
using Product;
using nspLable.Function;
using UserInfo;
using Area;
using VipGrade;
using Base;
using System.Text.RegularExpressions;
namespace nspLable.Function.Systems
{
    /// <summary>
    /// SupplyLable 的摘要说明
    /// </summary>
    public class clsProductLable : nspLable.Function.Systems.systemic
    {


        /// <summary>
        /// 产品图文标签
        /// </summary>
        /// <param name="Array（13）">
        /// Num	        信息列表数目	
        /// RowsNum	    每行的列数	
        /// ProAttribute	信息列表属性	
        /// WhitchType	列表显示样式(0:只有图片，1: 图文)
        /// TypeID      类型（0：供应，1：求购）
        /// IndType     行业类别
        /// OrderBy	    排序方式（0：ID升序；1：ID降序；2：时间升序；3：时间降序）	
        /// PicHeight	图片宽度	
        /// PicWidth	图片高度	
        /// PicClass	图片样式	
        /// TitleSize	标题最多字符数	
        /// TitleClass	标题样式	
        /// Target---（链接目标）
        /// <returns></returns>
        public static string SY_Productlist_Pic(TSystemLable Array)
        {
            // 分解的参数信息
            string[] strContent;
            strContent = Array.Info.Split(new char[] { '|' });

            //初始化参数,如果参数不够则跳出
            if (strContent.Length != 13) return Function.ErrInfo(0);

            int Num = 0;
            int RowsNum = 0;
            int WhichType = 0;
            int TypeID = 0;
            int OrderBy = 0;
            int PicWidth = 0;
            int PicHight = 0;
            int TitleSize = 0;
            if (strContent[0].ToString().Trim() != "") Num = Convert.ToInt32(strContent[0].ToString());
            if (strContent[1].ToString().Trim() != "") RowsNum = Convert.ToInt32(strContent[1].ToString());
            string ProAttribute = strContent[2].ToString();
            if (strContent[3].ToString().Trim() != "") WhichType = Convert.ToInt32(strContent[3].ToString());
            if (strContent[4].ToString().Trim() != "") TypeID = Convert.ToInt32(strContent[4].ToString());
            string IndType = strContent[5].ToString();
            if (strContent[6].ToString().Trim() != "") OrderBy = Convert.ToInt32(strContent[6].ToString());
            if (strContent[7].ToString().Trim() != "") PicWidth = Convert.ToInt32(strContent[7].ToString());
            if (strContent[8].ToString().Trim() != "") PicHight = Convert.ToInt32(strContent[8].ToString());
            string PicClass = strContent[9].ToString();
            if (strContent[10].ToString().Trim() != "") TitleSize = Convert.ToInt32(strContent[10].ToString());
            string TitleClass = strContent[11].ToString();
            string Target = strContent[12].ToString();

            //需要取得的数据
            string strSelect;
            //读取几条信息
            if (Num <= 0)
                strSelect = "top 1  ID,Name,Thumbnail";
            else
                strSelect = " top " + Num + " ID,Name,Thumbnail ";


            //要查询的表、视图、存储过程
            string strTableName = "";
            if (TypeID < 0) TypeID = 0;
            //显示供应还是求购           
            if (TypeID == 1)
                strTableName = "C_Purchase";
            else
                strTableName = "C_Supply";


            //查询条件
            String strWhere = "where Verify=1";
            //所属类型 
            if (IndType.ToString().Length > 0 && IndType != "0")
            {
                //strWhere.Append("and IndType like %");
                //strWhere.Append(IndType);
                //strWhere.Append("% ");
                strWhere += " and patindex('%," + IndType + ",%' , ','+IndType+',')>0 ";
            }
            // 产品属性
            if (ProAttribute != "")
            {
                if (ProAttribute == "0")
                {
                    strWhere += "and Recommend = 1 ";
                }
                else
                {
                    strWhere += "and Recommend = 0 ";
                }

            }

            // 排序方式
            string strOrder = "";
            if (OrderBy < 0) OrderBy = 0;
            switch (OrderBy)
            {
                case 0:
                    strOrder = "order by ID desc";
                    break;
                case 1:
                    strOrder = "order by ID asc";
                    break;
                case 2:
                    strOrder = "order by AddDate asc";
                    break;
                case 3:
                    strOrder = "order by AddDate desc";
                    break;

            }
            //获取数据表
            DataTable ProductList = Function.GetDataTable(strSelect, strWhere, strTableName, strOrder);
            StringBuilder strBuilder = new StringBuilder();
            if (ProductList.Rows.Count <= 0) return "没有相关产品";
            strBuilder.Append("<table width='100%' border='0' cellspacing='0' cellspadding='0'><tr><td>");
            for (int i = 0; i < ProductList.Rows.Count; i++)
            {
                if (i > Num - 1) break; //如果超过显示的条数则跳出。
                switch (WhichType)
                {
                    case 0:  //只显示图片
                        strBuilder.Append(@"<table  border='0' cellspacing='0' cellspadding='0'><tr><td>");
                        if (TypeID == 0)
                            strBuilder.Append(@"<a href='{PB_WebURL}Supply/Detail-");
                        else
                            strBuilder.Append(@"<a href='{PB_WebURL}Purchase/Detail-");
                        strBuilder.Append(ProductList.Rows[i]["ID"].ToString());
                        strBuilder.Append(BasePage.Config.Rewrite);
                        strBuilder.Append(@" ' Target='");
                        strBuilder.Append(Target);
                        strBuilder.Append(@"'>");
                        strBuilder.Append("<img width='");
                        strBuilder.Append(PicWidth);
                        strBuilder.Append(@"' height='");
                        strBuilder.Append(PicHight);
                        if (PicClass != "" || PicClass != null)
                        {
                            strBuilder.Append(@"' class='");
                            strBuilder.Append(PicClass);
                            strBuilder.Append(@"'");
                        }
                        strBuilder.Append(" src='");
                        strBuilder.Append(Function.ProcessImageUrl(ProductList.Rows[i]["Thumbnail"].ToString()));
                        strBuilder.Append(@"'></a>");
                        strBuilder.Append(@"</td></tr></table>");
                        break;
                    case 1: //显示文字
                        strBuilder.Append(@"<table  border='0' cellspacing='0' cellspadding='0'><tr><td>");
                        if (TypeID == 0)
                            strBuilder.Append(@"<a href='{PB_WebURL}Supply/Detail-");
                        else
                            strBuilder.Append(@"<a href='{PB_WebURL}Purchase/Detail-");
                        strBuilder.Append(ProductList.Rows[i]["ID"].ToString());
                        strBuilder.Append(BasePage.Config.Rewrite);
                        strBuilder.Append(@" ' Target='" + "");
                        strBuilder.Append(Target);
                        strBuilder.Append(@"'>");
                        strBuilder.Append("<img width='");
                        strBuilder.Append(PicWidth);
                        strBuilder.Append(@"' height='");
                        strBuilder.Append(PicHight + "'");
                        if (PicClass != "" || PicClass != null)
                        {
                            strBuilder.Append(@" class='");
                            strBuilder.Append(PicClass);
                            strBuilder.Append(@"'");
                        }
                        strBuilder.Append(" src='");
                        strBuilder.Append(Function.ProcessImageUrl(ProductList.Rows[i]["Thumbnail"].ToString()));
                        strBuilder.Append(@"'></a></td></tr><tr><td>");
                        if (TypeID == 1)
                            strBuilder.Append(@"<a href='{PB_WebURL}Purchase/Detail-");
                        else
                            strBuilder.Append(@"<a href='{PB_WebURL}Supply/Detail-");
                        strBuilder.Append(ProductList.Rows[i]["ID"].ToString());
                        strBuilder.Append(BasePage.Config.Rewrite);
                        strBuilder.Append(@"' Target='" + Target + "' class=\"" + TitleClass + "\">");
                        if (TitleClass != "" || TitleClass != null)
                            strBuilder.Append(Function.GetString(ProductList.Rows[i]["Name"].ToString(), TitleSize));
                        strBuilder.Append(@"</a>");
                        strBuilder.Append(@"</td><tr></table>");
                        break;
                    default:
                        strBuilder.Append(@"<table  border='0' cellspacing='0' cellspadding='0'><tr><td>");
                        strBuilder.Append(" ");
                        strBuilder.Append(@"</td></tr></table>");
                        break;

                }

                //换行
                if (((i + 1) % RowsNum) == 0)
                {
                    if (i == (Num - 1))
                        strBuilder.Append(@" ");
                    else
                        strBuilder.Append(@"</td></tr><tr><td>");
                }
                else
                    strBuilder.Append(@"</td><td>");
            }
            strBuilder.Append(@"</td></tr></table>");
            return strBuilder.ToString();
        }

        /// <summary>
        /// 产品文字列表
        /// </summary>
        /// <param name="Array（10）">
        /// Num	          显示条数      
        /// RowsNum	      每行显示几条
        /// TypeID        [0：供应,1：求购]	
        /// IndType	      行业类别
        /// ProAttribute  商机属性
        /// OrderBy	      排序方式
        /// TitleSize	  标题字数	
        /// TitleClass    标题样式
        /// isShow	      是否显示 [供应/求购,时间]{0：不显示，1：显示}
        /// Target	      打开方式 [_blank ,_self]
        /// </param>
        /// <returns></returns>
        public static string SY_Productlist_Str(TSystemLable Array)
        {
            // 分解的参数信息
            string[] strContent;
            strContent = Array.Info.Split(new char[] { '|' });

            //初始化参数,如果参数不够则跳出
            if (strContent.Length != 10) goto Err;

            int Num = strContent[0].ToString().Length > 0 ? Convert.ToInt32(strContent[0].ToString()) : 0;
            int RowsNum = strContent[1].ToString().Length > 0 ? Convert.ToInt32(strContent[1].ToString()) : 0;
            string TypeID = strContent[2].ToString();
            string IndType = strContent[3].ToString();
            string ProAttribute = strContent[4].ToString();
            string OrderBy = strContent[5].ToString();
            int TitleSize = strContent[6].ToString().Length > 0 ? Convert.ToInt32(strContent[6].ToString()) : 0;
            string TitleClass = strContent[7].ToString();
            char isType = strContent[8].ToString().Length > 0 ? strContent[8].ToString()[0] : '0';
            char isAddDate = strContent[8].ToString().Length > 2 ? strContent[8].ToString()[2] : '0';
            string Target = strContent[9].ToString();

            //需要取得的数据
            string strSelect;
            //读取几条信息
            if (Num <= 0)
                strSelect = "top 1 ";
            else
                strSelect = " top " + Num;

            if (TypeID == "1")
                strSelect += " C_Purchase.ID as ID , Name";
            else
                strSelect += " C_Supply.ID as ID , Name";


            if (isAddDate == '1') strSelect += " , AddDate";
            if (isType == '1') strSelect += ",Type,IndType ";

            //要查询的表、视图、存储过程
            string strTableName = "";
            //显示供应还是求购           
            if (TypeID == "1")
                strTableName = "C_Purchase";
            else
                strTableName = "C_Supply";
            if (isType == '1') strTableName += " , W_IndustryType";

            //查询条件
            StringBuilder strWhere = new StringBuilder();
            //所属类型 
            strWhere.Append("where verify=1 ");
            if (TypeID == "1" && isType == '1')
                strWhere.Append("and ','+ C_Purchase.IndType like +'%,'+ CAST(W_IndustryType.ID AS varchar)");
            else if (TypeID == "0" && isType == '1')
                strWhere.Append("and ','+ C_Supply.IndType like +'%,'+ CAST(W_IndustryType.ID AS varchar)");
            if (IndType.ToString().Length > 0 && IndType.ToString() != "0")
            {
                strWhere.Append(" and patindex('%," + IndType + ",%' , ','+IndType+',')>0 ");
            }
            // 资讯属性
            //if (ProAttribute != "")
            //{
            //    if (ProAttribute == "0")
            //    {
            //        strWhere.Append("and Recommend = 'False' ");
            //    }
            //    else
            //    {
            //        strWhere.Append("and Recommend = 'False' ");
            //    }
            //}

            // 排序方式
            string strOrder = "";
            switch (OrderBy)
            {
                case "0":
                    strOrder = "order by ID asc";
                    break;
                case "1":
                    strOrder = "order by ID desc";
                    break;
                case "2":
                    strOrder = "order by AddDate asc";
                    break;
                case "3":
                    strOrder = "order by AddDate desc";
                    break;
                default:
                    strOrder = "order by AddDate desc";
                    break;
            }
            //获取数据表
            DataTable ProductList = Function.GetDataTable(strSelect, strWhere.ToString(), strTableName, strOrder);
            if (ProductList.Rows.Count <= 0)
            {
                return "暂无该信息";
            }
            StringBuilder strBuilder = new StringBuilder();
            int intCount = ProductList.Rows.Count;
            int intRow = 0;
            int intCell = RowsNum;
            intRow = intCount % intCell == 0 ? intCount / intCell : intCount / intCell + 1;
            strBuilder.Append("<table width='100%'  border=\"0\" cellpadding=\"0\" cellspacing=\"0\">" + "\r\n ");
            for (int i = 0; i < intRow; i++)
            {
                strBuilder.Append("<tr>" + "\r\n ");
                for (int j = 0; j < intCell; j++)
                {
                    int m = i * intCell + j;
                    if (m > Num || m >= intCount) break; //如果超过显示的条数则跳出。
                    strBuilder.Append("<td");
                    if (TitleClass != null || TitleClass != "")
                    {
                        strBuilder.Append(" class='" + TitleClass + "'");
                    }
                    strBuilder.Append(">");



                    if (isType == '1')
                    {
                        strBuilder.Append(@"[");
                        if (TypeID == "0")
                            strBuilder.Append(@"<a href='{PB_WebURL}Supply/Trade-");
                        else
                            strBuilder.Append(@"<a href='{PB_WebURL}Purchase/Trade-");
                        if (ProductList.Rows[m]["IndType"].ToString().LastIndexOf(',') > 0)
                            strBuilder.Append(ProductList.Rows[m]["IndType"].ToString().Substring(ProductList.Rows[m]["IndType"].ToString().LastIndexOf(',') + 1));
                        else
                            strBuilder.Append(ProductList.Rows[m]["IndType"].ToString());
                        strBuilder.Append(BasePage.Config.Rewrite);
                        strBuilder.Append(@" ' Target='");
                        strBuilder.Append(Target);
                        strBuilder.Append(@"'>");
                        strBuilder.Append(ProductList.Rows[m]["Type"].ToString());
                        strBuilder.Append(@"</a>]");
                    }
                    if (TypeID == "0")
                        strBuilder.Append(@"<a href='{PB_WebURL}Supply/Detail-");
                    else
                        strBuilder.Append(@"<a href='{PB_WebURL}Purchase/Detail-");
                    strBuilder.Append(ProductList.Rows[m]["ID"].ToString());
                    strBuilder.Append(BasePage.Config.Rewrite);
                    strBuilder.Append(@"' Target='");
                    strBuilder.Append(Target);
                    strBuilder.Append(@"'>"); strBuilder.Append("  ");
                    if (TitleSize > 0) //设置标题字数
                        if (ProductList.Rows[m]["Name"].ToString().Length > TitleSize)
                            strBuilder.Append(ProductList.Rows[m]["Name"].ToString().Substring(0, TitleSize));
                        else
                            strBuilder.Append(ProductList.Rows[m]["Name"].ToString());
                    else
                        strBuilder.Append(ProductList.Rows[m]["Name"].ToString());
                    strBuilder.Append(@"</a>    ");
                    if (isAddDate == '1')
                        strBuilder.Append(DateTime.Parse(ProductList.Rows[m]["AddDate"].ToString()).ToShortDateString());
                    strBuilder.Append("</td>");
                }
                strBuilder.Append("</tr>" + "\r\n ");
            }
            strBuilder.Append(@"</table>" + "\r\n ");
            return strBuilder.ToString();

        Err:
            return Function.ErrInfo(0);

        }

        /// <summary>
        /// 转换求购详细页的私有变量
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static string PR_PurchaseDetail(string Restr, string str)
        {
            // 分解传递过来的数据，取得模板内所有的私有标签
            string[] strArray;
            strArray = str.Split('|');
            int PID = 0;
            PID = Convert.ToInt32(HttpContext.Current.Request.QueryString["ID"]);
            TPurchase Items = new RPurchase().GateItem(PID);
            if (Items.ID <= 0)
            {
                HttpContext.Current.Response.Write("<script>location.href='/Error.aspx?err=5';</script>");
            }
            try
            {
                for (int i = 0; i < strArray.Length; i++)
                {
                    switch (strArray[i].ToString().ToUpper())
                    {
                        case "{PR_KEYWORD}":
                            Restr = Restr.Replace(strArray[i].ToString(), Items.Name);
                            break;
                        case "{PR_NAME}":
                            Restr = Restr.Replace(strArray[i].ToString(), Items.Name.ToString());
                            break;
                        case "{PR_MATEKEYWORD}":             //Matekeyword
                            Restr = Restr.Replace(strArray[i].ToString(), Items.Key.ToString());
                            break;
                        case "{PR_MATEDESCRIPTION}":         //
                            Restr = Restr.Replace(strArray[i].ToString(), Items.Name.ToString());
                            break;
                        case "{PR_TYPELINK}":                //类别列表
                            string strTypeLink = "";
                            if (Items.IndType.ToString() != "")
                            {
                                strTypeLink = TypeLink(Items.IndType.ToString(), 1);
                                Restr = Restr.Replace(strArray[i].ToString(), strTypeLink);
                            }

                            break;
                        case "{PR_TYPENAME}":                //类别名称
                            string strTypenName = "";
                            strTypenName = TypeLink(Items.IndType.ToString(), 0);
                            string str1 = Base.Common.ClearHtml(strTypenName);
                            Restr = Restr.Replace(strArray[i].ToString(), str1.Substring(str1.LastIndexOf('>') + 1).Trim());
                            break;
                        case "{PR_PICTURE}":                 //图片
                            Restr = Restr.Replace(strArray[i].ToString(), Function.ProcessImageUrl(Items.Thumbnail.ToString()));
                            break;
                        case "{PR_PICBIG}":                 //图片链接
                            Restr = Restr.Replace(strArray[i].ToString(), Items.Thumbnail.Replace("t_","m_"));
                            break;
                        case "{PR_ID}":                      //求购ID
                            Restr = Restr.Replace(strArray[i].ToString(), Items.ID.ToString());
                            break;
                        case "{PR_INFO}":                    //求购信息
                            Restr = Restr.Replace(strArray[i].ToString(), Items.Info.ToString());
                            break;
                        case "{PR_EXPIRYDATE}":              //有效期
                            string strExpiryDate = "";
                            strExpiryDate += Function.DateTransform(Items.StartDate.ToString(), "yyyy-mm-dd") + " - ";
                            strExpiryDate += Function.DateTransform(Items.EndDate.ToString(), "yyyy-mm-dd");
                            Restr = Restr.Replace(strArray[i].ToString(), strExpiryDate);
                            break;
                        case "{PR_COUNT}":                   //求购数量
                            Restr = Restr.Replace(strArray[i].ToString(), Items.Count.ToString());
                            break;
                        case "{PR_PRICE}":                   //单价
                            Restr = Restr.Replace(strArray[i].ToString(), Items.Price.ToString());
                            break;
                        case "{PR_UNIT}":                    //单位
                            Restr = Restr.Replace(strArray[i].ToString(), Items.Unit.ToString());
                            break;
                        case "{PR_AREA}":                    //地区
                            Restr = Restr.Replace(strArray[i].ToString(), GetUserInfo(Items.UserID, "area"));
                            break;
                        case "{PR_ADDDATE}":                 //发布日期
                            Restr = Restr.Replace(strArray[i].ToString(), Function.DateTransform(Items.AddDate.ToString(), "yyyy-mm-dd"));
                            break;
                        case "{PR_INTERRELATED}":           //相关求购产品
                            Restr = Restr.Replace(strArray[i].ToString(), Purchase_Interrelated(Items.Key.ToString(), PID));
                            break;
                        case "{PR_MODEL}":                  //相关求购产品
                            Restr = Restr.Replace(strArray[i].ToString(), Items.Model.ToString());
                            break;
                        case "{PR_USERNAME}":               //
                            Restr = Restr.Replace(strArray[i].ToString(), GetUserInfo(Items.UserID, "loginname"));
                            break;
                        case "{PR_USERGRADE}":              //会员等级
                            if (Items.IsUser.Equals("True"))
                                Restr = Restr.Replace(strArray[i].ToString(), GetUserInfo(Items.UserID, "grade"));
                            else
                                Restr = Restr.Replace(strArray[i].ToString(), "非会员");
                            break;
                        case "{PR_COUNTYEAR}":               //第几年
                            if (Items.IsUser.Equals("True"))
                            {
                                string year = "1";
                                DateTime StartDate = DateTime.Parse(GetUserInfo(Items.UserID, "StartDate"));
                                if (((DateTime.Now.Year) - (StartDate.Year)) == 0)
                                    year = "1";
                                else if (((DateTime.Now.Year) - (StartDate.Year)) > 0)
                                    year = ((DateTime.Now.Year) - (StartDate.Year)).ToString();
                                Restr = Restr.Replace(strArray[i].ToString(), "第" + year + "年");
                            }
                            else
                                Restr = Restr.Replace(strArray[i].ToString(), "");
                            break;
                        case "{PR_COMPANYNAME}":            //公司名称
                            Restr = Restr.Replace(strArray[i].ToString(), GetUserInfo(Items.UserID, "companyname"));
                            break;
                        case "{PR_BUSSINESSMODEL}":            //公司性质
                            Restr = Restr.Replace(strArray[i].ToString(), GetUserInfo(Items.UserID, "BusinessModel"));
                            break;
                        case "{PR_SAVEFAVORITES}":          //收藏信息
                            Restr = Restr.Replace(strArray[i].ToString(), systemic.PR_SaveFavorites(Items.ID.ToString(), "purchase"));
                            break;
                        case "{PR_QUOTATION}":              //报价
                            Restr = Restr.Replace(strArray[i].ToString(), "{PB_WebUrl}Search/Quotation.aspx?id=" + Items.ID.ToString());
                            break;
                        case "{PR_STARTDATE}":              //
                            Restr = Restr.Replace(strArray[i].ToString(), Items.StartDate.ToShortDateString());
                            break;
                        case "{PR_ENDDATE}":              //
                            Restr = Restr.Replace(strArray[i].ToString(), Items.EndDate.ToShortDateString());
                            break;
                        default:
                            // Restr = Restr.Replace(strArray[i].ToString(), strArray[i].ToString());
                            break;

                    }
                }
            }
            catch (Exception e)
            {
                // Restr = Restr + e.Message.ToString();
            }
            return Restr;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="p">会员ID</param>
        /// <param name="param">要查找的字段</param>
        /// <returns></returns>
        private static string GetUserInfo(int p, string param)
        {
            string Restr = "";
            UserInfo.TUserInfo Items = new UserInfo.RUserInfo().GateItem(p);
            if (Items.UserID == 0)
            {
                // HttpContext.Current.Response.Redirect("/Error.aspx");
                return "";
            }


            switch (param.ToUpper())
            {
                case "AREA":               //地区
                    if (Items.Country == "中国")
                        Restr += Items.Province + " " + Items.City;
                    else
                        Restr += Items.Country;
                    break;
                case "COMPANYNAME":        //公司名称
                    Restr += Items.CompanyName;
                    break;
                case "LOGINNAME":          //会员名称
                    Restr += Items.LoginName;
                    break;
                case "QQ":                //QQ
                    Restr += Items.QQ;
                    break;
                case "GRADE":             //会员等级
                    DataTable Grade = new VipGrade.RVipGrade().GetDataTable(Convert.ToInt32(Items.GradeID.ToString()));
                    Restr += Grade.Rows[0]["Name"].ToString();
                    break;
                case "BUSINESSMODEL":
                    Restr += Items.BusinessModel.ToString();
                    break;
                case "STARTDATE":
                    Restr += Items.StartDate.ToString();
                    break;
            }
            return Restr.ToString();
        }

        /// <summary>
        /// 相关求购产品
        /// </summary>
        /// <returns></returns>
        private static string Purchase_Interrelated(string strkey, int ID)
        {
            StringBuilder Restr = new StringBuilder();
            try
            {
                Product.TPurchase PurchaseItems = new Product.RPurchase().GateItem(ID);
                string[] strTable;
                string strWhere = " where  C_Purchase.UserID=U_UserInfo.UserID and C_Purchase.Id!=" + ID + " and C_Purchase.UserID=" + PurchaseItems.UserID;
 
                DataTable Tables = Function.GetDataTable(" C_Purchase.* , U_UserInfo.CompanyName ", strWhere, "C_Purchase ,U_UserInfo", "order by C_Purchase.AddDate");
                if (Tables.Rows.Count < 0)
                    Restr.Append("没有相关求购信息");
                else
                {
                    Restr.Append(@"<table cellpadding='0' cellspacing='0' border='0' class='sptab2'><thead><tr><td>采购产品</td><td>采购量</td><td>价格说明</td><td>公司</td><td>发布时间</td></tr></thead><tbody>");
                    for (int i = 0; i < Tables.Rows.Count; i++)
                    {
                        Restr.Append("<tr><td><a href=\"{PB_WEBURL}Purchase/detail-");
                        Restr.Append(Tables.Rows[i]["ID"].ToString() + BasePage.Config.Rewrite + "\">");
                        Restr.Append(Tables.Rows[i]["Name"].ToString());
                        Restr.Append("</a></td><td>");
                        Restr.Append(Tables.Rows[i]["Count"].ToString());
                        Restr.Append("</td><td>");
                        Restr.Append(Tables.Rows[i]["Price"].ToString());
                        Restr.Append("</td><td>");
                        Restr.Append(Tables.Rows[i]["CompanyName"].ToString());
                        Restr.Append("</td><td>");
                        Restr.Append(Tables.Rows[i]["AddDate"].ToString());
                        Restr.Append("</td><tr>");
                    }
                    Restr.Append("</tbody></table>");
                }
            }
            catch (Exception e)
            {
                Restr.Append(e.Message.ToString());
            }
            return Restr.ToString();
        }


        /// <summary>
        /// 行业类别链表
        /// </summary>
        /// <param name="strType">行业ID字符串</param>
        /// <param name="param">0:分类页, 1:详细页</param>
        /// <returns></returns>
        private static string TypeLink(string strTypeLink, int param)
        {
            if (strTypeLink[strTypeLink.Length - 1] == ',')
            {
                strTypeLink = strTypeLink.Substring(0, strTypeLink.Length - 1);
            }
            try
            {
                DataTable TypeData = new DataTable();
                if (param != 0)
                    TypeData = Function.GetDataTable("Type,ID", "where ID in(" + strTypeLink + ") AND ToRelease=1 ", "W_IndustryType", " order by SuperiorsFlag  ");
                else
                {
                    SqlParameter[] param1 = new SqlParameter[] 
                    {  
                        new SqlParameter("@ID",Convert.ToInt32(strTypeLink))
                    };
                    TypeData = SqlOperate.SqlHelper.ExecuteTable(CommandType.StoredProcedure, "SP_W_TypeLink", param1);
                }
                string strType = "";
                string str = "<a href='trade-";

                if (TypeData.Rows.Count > 0)
                {
                    for (int i = 0; i < TypeData.Rows.Count; i++)
                    {
                        strType += " > " + str;
                        strType += TypeData.Rows[i]["ID"].ToString() + BasePage.Config.Rewrite;
                        strType += "'>";
                        strType += TypeData.Rows[i]["Type"].ToString();
                        strType += "</a>";
                    }
                }
                return strType;
            }
            catch (Exception ex)
            {
                return "";
            }
        }

        /// <summary>
        /// 详细页行业类别链表
        /// </summary>
        /// <param name="param">0:求购分类页, 1:求购详细页, 2:供应分类页, 3:供应详细页</param>
        /// <returns></returns>
        private static string TypeLink(string strTypeLink)
        {
            return TypeLink(strTypeLink, 1);
        }

        /// <summary>
        ///  求购列表（仅限在求购分类页中使用）
        /// </summary>
        /// <param name="Array"></param>
        /// <returns></returns>
        public static string DIY_Purchaselist(TSystemLable Array, string strModule)
        {
            System.Collections.Specialized.NameValueCollection nv = System.Web.HttpUtility.ParseQueryString(System.Web.HttpContext.Current.Request.Url.Query, System.Text.Encoding.GetEncoding("utf-8"));

            // 对标签使用条件进行检查
            if (strModule == "" || strModule.Substring(0, strModule.IndexOf('_')) != "Purchase") throw new Exception(Function.ErrInfo(2));
            string strWhere = " C_Purchase.Verify=1 and (datediff(hh,C_Purchase.EndDate,getdate())<0)";
            int TypeID = 0;
            if (Function.CheckQueryStringisInt("id"))
            {
                TypeID = Convert.ToInt32(HttpContext.Current.Request.QueryString["ID"]);
                strWhere += " and patindex('%,'+rtrim( " + TypeID + ")+',%',','+ IndType+',')>0 ";
            }
            string purchaseName = "";
            if (HttpContext.Current.Request.QueryString["sName"] != null)
            {
                purchaseName = System.Web.HttpUtility.UrlDecode(HttpContext.Current.Request.QueryString["sName"]);
            }
            if (purchaseName != "")
            {
                strWhere += " and C_Purchase.Name like '%" + purchaseName + "%' ";
            }

            if (TypeID < 0) throw new Exception(Function.ErrInfo(1));

            // 定义全局变量，最后返回
            StringBuilder ReBulider = new StringBuilder();

            // 求购列表头部
            string strHead = "";
            strHead = Array.Head;
            ReBulider.Append(strHead);

            //取得页尺寸
            int pagesize = 10;
            int OrderType = 1;               
            int PageID = 1;  //x
            if (Function.CheckQueryStringisInt("Page"))
            {
                PageID = Convert.ToInt32(HttpContext.Current.Request.QueryString["Page"]);
            }

            string strTabelName = "C_Purchase Left join U_UserInfo on C_Purchase.UserID=U_UserInfo.UserID ";
            string strFldName = "AddDate";
            string strSelect = "C_Purchase.*,U_UserInfo.UserID, U_UserInfo.GradeID";           
            if (Array.Info != null)
            {
                string[] strInfo1 = Array.Info.Split('|');
                for (int k = 0; k < strInfo1.Length; k++)
                {
                    if (k == 0)
                    {
                        if (GetRequest.isNum(strInfo1[k].ToString()))
                        {
                            pagesize = Int32.Parse(strInfo1[k].ToString());
                        }
                    }
                    else if (k == 1)
                    {
                        if (GetRequest.isNum(strInfo1[k].ToString()))
                        {
                            string strType = strInfo1[k].ToString();
                            switch (strType)
                            {
                                case "0": OrderType = 0; strFldName = " C_Purchase.AddDate asc, U_UserInfo.GradeID "; break;
                                case "1": OrderType = 1; strFldName = " C_Purchase.AddDate desc, U_UserInfo.GradeID "; break;
                                case "2": OrderType = 1; strFldName = " U_UserInfo.GradeID desc, C_Purchase.AddDate "; break;
                                case "3": OrderType = 0; strFldName = " U_UserInfo.GradeID asc, C_Purchase.AddDate "; break;
                            }
                        }
                    }
                }
            }     
            // 获取求购信息U_VipGrade.Sort desc,AddDate
            DataTable Lists = Pagination.GetDataTable(strWhere, strTabelName, OrderType, strFldName, strSelect, pagesize, PageID, 0, "C_Purchase.id");
            if (Lists.Rows.Count < 0)
            {
                ReBulider.Append("暂无此类产品");
            }
            else
            {
                DataSet vipData = new VipGrade.RVipGrade().GetDataTable();
                string strInfo = Array.Content.ToString();
                string[] strAtttibute = Function.GetAttribute(strInfo);
                for (int i = 0; i < Lists.Rows.Count; i++)
                {
                    strInfo = Array.Content.ToString();
                    for (int j = 0; j < strAtttibute.Length; j++)
                    {
                        switch (strAtttibute[j].ToUpper())
                        {
                            case "{PR:WS_ID}":
                                strInfo = strInfo.Replace(strAtttibute[j].ToString(), Lists.Rows[i]["ID"].ToString());
                                break;
                            case "{PR:WS_NAME}":
                                strInfo = strInfo.Replace(strAtttibute[j].ToString(), Lists.Rows[i]["Name"].ToString());
                                break;
                            case "{PR:WS_PICTURE}":
                                strInfo = strInfo.Replace(strAtttibute[j].ToString(), Function.ProcessImageUrl(Lists.Rows[i]["Thumbnail"].ToString()));
                                break;                           
                            case "{PR:WS_ADDDATE}":
                                strInfo = strInfo.Replace(strAtttibute[j].ToString(), Convert.ToDateTime(Lists.Rows[i]["AddDate"].ToString()).ToShortDateString());
                                break;
                            case "{PR:WS_INFO}":
                                strInfo = strInfo.Replace(strAtttibute[j].ToString(), Function.GetString(Base.Common.RemoveHTML(Lists.Rows[i]["Info"].ToString()), 60));
                                break;
                            case "{PR:WS_LEVEL}":
                                if ((Lists.Rows[i]["IsUser"].ToString()).Equals("False"))
                                {
                                    strInfo = strInfo.Replace(strAtttibute[j].ToString(), "非会员");
                                }
                                else
                                {
                                    for (int k = 0; k < vipData.Tables[0].Rows.Count; k++)
                                    {
                                        if (Lists.Rows[i]["GradeID"].ToString() == vipData.Tables[0].Rows[k]["ID"].ToString())
                                        {
                                            strInfo = strInfo.Replace(strAtttibute[j].ToString(), "<img src=\"" + Function.ProcessImageUrl(vipData.Tables[0].Rows[k]["Flag"].ToString()) + "\"/>");
                                            break;
                                        }
                                    }
                                }
                                break;
                            case "{PR:WS_GALAXIECHAT}":           //在线交流
                                string str1 = GetUserInfo(Convert.ToInt32(Lists.Rows[i]["UserID"].ToString()), "qq");
                                string str = "";
                                if (str1 != "")
                                    str = "<a target=\"blank\" href=\"http://wpa.qq.com/msgrd?V=1&Uin=" + str1 + "&Exe=QQ&Site=im.qq.com&Menu=No\"><img style=\" border:0\" src=\"{pb_weburl}images/b_online.gif\" alt=\"给我发消息\" /></a>";
                                if (HttpContext.Current.Request.Cookies["UserID"] != null && HttpContext.Current.Request.Cookies["UserID"].ToString() != "")
                                {
                                    strInfo = strInfo.Replace(strAtttibute[j].ToString(), str);
                                }
                                else
                                {
                                    strInfo = strInfo.Replace(strAtttibute[j].ToString(), "<img style=\" border:0\" src=\"{pb_weburl}images/b_online.gif\" alt=\"给我发消息\" onclick=\"javascript:alert('您还没有登陆，请先登陆')\" />");
                                }
                                break;
                            case "{PR:WS_AREA}":                  //地区
                                strInfo = strInfo.Replace(strAtttibute[j].ToString(), GetUserInfo(Convert.ToInt32(Lists.Rows[i]["UserID"].ToString()), "area"));
                                break;

                            case "{PR:WS_PRICE}":                 //价格
                                strInfo = strInfo.Replace(strAtttibute[j].ToString(), Lists.Rows[i]["Price"].ToString() + "元/" + Lists.Rows[i]["Unit"].ToString());
                                break;
                            case "{PR:WS_COMPANYNAME}":
                                if (HttpContext.Current.Request.Cookies["UserID"] != null && HttpContext.Current.Request.Cookies["UserID"].ToString() != "")
                                {
                                    strInfo = strInfo.Replace(strAtttibute[j].ToString(), GetUserInfo(Convert.ToInt32(Lists.Rows[i]["UserID"].ToString()), "companyname"));
                                }
                                else
                                {
                                    strInfo = strInfo.Replace(strAtttibute[j].ToString(), "&nbsp;");
                                }
                                break;
                            case "{PR:WS_DETAILLINK}":
                                strInfo = strInfo.Replace(strAtttibute[j].ToString(), "{PB_WEBURL}Purchase/detail-" + Lists.Rows[i]["ID"].ToString() + BasePage.Config.Rewrite);
                                break;
                            case "{PR:WS_SHOPURL}":
                                if (HttpContext.Current.Request.Cookies["UserID"] != null && HttpContext.Current.Request.Cookies["UserID"].ToString() != "")
                                {
                                    strInfo = strInfo.Replace(strAtttibute[j].ToString(), "{PB_WEBURL}Shops/index/" + GetUserInfo(Convert.ToInt32(Lists.Rows[i]["UserID"].ToString()), "LoginName") + Base.BasePage.Config.Rewrite);
                                }
                                else
                                {
                                    strInfo = strInfo.Replace(strAtttibute[j].ToString(), "#");
                                }
                                break;
                            case "{PR:WS_CHECKINFO}":
                                strInfo = strInfo.Replace(strAtttibute[j].ToString(), "<input id=\"compareBox" + i + "\" type=\"checkbox\" value=\"\" name=\" " + Lists.Rows[i]["id"].ToString() + " \" onclick=\"clickcompareBox(" + Lists.Rows[i]["id"].ToString() + ",this)\" memberId=\"stfseal\">");
                                break;
                        }

                    }
                    if (i > pagesize) break; //如果超过显示的条数则跳出。
                    ReBulider.Append(strInfo);
                }
            }
            ReBulider.Append("</ul>");
            ReBulider.Append("<div class=\"ltnr3 mar_top\"><p class=\"w8\"></p><p class=\"w4\"><input type=\"button\" class=\"soso\" onclick=\"doInquiry('purchase')\" value=\"批量报价\" /></p><p class=\"w6\"><input type=\"button\" class=\"qink\" onclick=\"clearCheck()\" value=\"清空全部选择\" /></p><p class=\"w7\"><a title=\"\" target=\"_blank\" class=\"l_c00_u\" href=\"{PB_WebURL}member/" + Base.BasePage.Config.Rewrite + "\">点此发布供应信息</a></p></div>");


            //求购列表尾部
            string strFooter = "";
            strFooter = Array.Footer;
            ReBulider.Append(strFooter);

            string strUrl = "{PB_WebURL}Purchase/Trade";
            if (PageID <= 0) PageID = 1;
            if (TypeID != 0)
            {
                strUrl += "-" + TypeID;
            }
            if (purchaseName != "")
            {
                strUrl += "-n" + purchaseName;
            }
            strUrl += "-p";
            string Pages = Pagination.GoToPager(PageID, pagesize, strUrl, strWhere, "C_Purchase");
            ReBulider.Append(Pages);
            return ReBulider.ToString();

        Err0:
            return Function.ErrInfo(2);
        }

        /// <summary>
        ///  求购列表（仅限在求购分类及搜索页中使用）
        /// </summary>
        /// <param name="Array"></param>
        /// <returns></returns>
        public static string DIY_Purchaselist_Search(TSystemLable Array, string strModule)
        {
            System.Collections.Specialized.NameValueCollection nv = System.Web.HttpUtility.ParseQueryString(System.Web.HttpContext.Current.Request.Url.Query, System.Text.Encoding.GetEncoding("utf-8"));

            // 对标签使用条件进行检查
            if (strModule == "" || strModule.Substring(0, strModule.IndexOf('_')) != "Purchase") throw new Exception(Function.ErrInfo(2));
            string strWhere = " C_Purchase.Verify=1 and (datediff(hh,C_Purchase.EndDate,getdate())<0)";
            int TypeID = 0;
            if (Function.CheckQueryStringisInt("id"))
            {
                TypeID = Convert.ToInt32(HttpContext.Current.Request.QueryString["ID"]);
                strWhere += " and patindex('%,'+rtrim( " + TypeID + ")+',%',','+ IndType+',')>0 ";
            }
            string purchaseName = "";
            if (HttpContext.Current.Request.QueryString["sName"] != null)
            {
                purchaseName = System.Web.HttpUtility.UrlDecode(HttpContext.Current.Request.QueryString["sName"]);
            }
            if (purchaseName != "")
            {
                strWhere += " and C_Purchase.Name like '%" + purchaseName + "%' ";
            }

            int regdate = 0;
            if (Function.CheckQueryStringisInt("regdate"))
            {
                regdate = Convert.ToInt32(HttpContext.Current.Request.QueryString["regdate"]);
                if (regdate == 1) strWhere += " and (DATEDIFF(year, C_Purchase.AddDate, GETDATE()) <= " + regdate + ") ";
                else strWhere += " and (DATEDIFF(year, C_Purchase.AddDate, GETDATE()) >= " + regdate + ") ";
            }

            string province = "";
            if (HttpContext.Current.Request.QueryString["pid"] != null)
            {
                province = System.Web.HttpUtility.UrlDecode(HttpContext.Current.Request.QueryString["pid"]);
            }
            if (province != "")
            {
                strWhere += " and U_UserInfo.Province like '%" + province + "%' ";
            }

            string city = "";
            if (HttpContext.Current.Request.QueryString["cid"] != null)
            {
                city = System.Web.HttpUtility.UrlDecode(HttpContext.Current.Request.QueryString["cid"]);
            }
            if (city != "")
            {
                strWhere += " and U_UserInfo.City like '%" + city + "%' ";
            }

            string area = "";
            if (HttpContext.Current.Request.QueryString["aid"] != null)
            {
                area = System.Web.HttpUtility.UrlDecode(HttpContext.Current.Request.QueryString["aid"]);
            }
            if (area != "")
            {
                strWhere += " and U_UserInfo.Area like '%" + area + "%' ";
            }

            if (TypeID < 0) throw new Exception(Function.ErrInfo(1));

            // 定义全局变量，最后返回
            StringBuilder ReBulider = new StringBuilder();

            // 求购列表头部
            string strHead = "";
            strHead = Array.Head;
            ReBulider.Append(strHead);

            //取得页尺寸
            int pagesize = 10;
            int strOrder = 0;
            int OrderType = 1;
            string strFldName = " U_VipGrade.Sort desc, C_Purchase.AddDate ";
            if (HttpContext.Current.Request.QueryString["sOrder"] != null)
            {
                strOrder = Convert.ToInt32(HttpContext.Current.Request.QueryString["sOrder"]);
                switch (strOrder)
                {
                    case 1:
                        OrderType = 1;
                        strFldName = " U_VipGrade.Sort desc, C_Purchase.Price ";
                        break;
                    case 2:
                        OrderType = 0;
                        strFldName = " U_VipGrade.Sort desc, C_Purchase.Price ";
                        break;
                    case 3:
                        OrderType = 1;
                        strFldName = " U_VipGrade.Sort desc, C_Purchase.AddDate ";
                        break;
                    case 4:
                        OrderType = 0;
                        strFldName = " U_VipGrade.Sort desc, C_Purchase.AddDate ";
                        break;
                }
            }
            int PageID = 1;  //x
            if (Function.CheckQueryStringisInt("Page"))
            {
                PageID = Convert.ToInt32(HttpContext.Current.Request.QueryString["Page"]);
            }

            string strTabelName = " C_Purchase Left join U_UserInfo on C_Purchase.UserID=U_UserInfo.UserID Left join U_VipGrade on U_UserInfo.GradeID=U_VipGrade.ID ";
            string strSelect = " C_Purchase.*,U_UserInfo.UserID, U_UserInfo.GradeID,U_VipGrade.ID as VipID";
            if (Array.Info != null)
            {
                string[] strInfo1 = Array.Info.Split('|');
                for (int k = 0; k < strInfo1.Length; k++)
                {
                    if (k == 0)
                    {
                        if (GetRequest.isNum(strInfo1[k].ToString()))
                        {
                            pagesize = Int32.Parse(strInfo1[k].ToString());
                            break;
                        }
                    }
                }
            }
            // 获取求购信息U_VipGrade.Sort desc,AddDate
            DataTable Lists = Pagination.GetDataTable(strWhere, strTabelName, OrderType, strFldName, strSelect, pagesize, PageID, 0, "C_Purchase.id");
            if (Lists.Rows.Count < 0)
            {
                ReBulider.Append("暂无此类产品");
            }
            else
            {
                DataSet vipData = new VipGrade.RVipGrade().GetDataTable();
                string strInfo = Array.Content.ToString();
                string[] strAtttibute = Function.GetAttribute(strInfo);
                for (int i = 0; i < Lists.Rows.Count; i++)
                {
                    strInfo = Array.Content.ToString();
                    for (int j = 0; j < strAtttibute.Length; j++)
                    {
                        switch (strAtttibute[j].ToUpper())
                        {
                            case "{PR:WS_ID}":
                                strInfo = strInfo.Replace(strAtttibute[j].ToString(), Lists.Rows[i]["ID"].ToString());
                                break;
                            case "{PR:WS_NAME}":
                                strInfo = strInfo.Replace(strAtttibute[j].ToString(), Lists.Rows[i]["Name"].ToString());
                                break;
                            case "{PR:WS_PICTURE}":
                                strInfo = strInfo.Replace(strAtttibute[j].ToString(), Function.ProcessImageUrl(Lists.Rows[i]["Thumbnail"].ToString()));
                                break;
                            case "{PR:WS_ADDDATE}":
                                strInfo = strInfo.Replace(strAtttibute[j].ToString(), Convert.ToDateTime(Lists.Rows[i]["AddDate"].ToString()).ToShortDateString());
                                break;
                            case "{PR:WS_INFO}":
                                strInfo = strInfo.Replace(strAtttibute[j].ToString(), Function.GetString(Base.Common.RemoveHTML(Lists.Rows[i]["Info"].ToString()), 60));
                                break;
                            case "{PR:WS_LEVEL}":
                                if ((Lists.Rows[i]["IsUser"].ToString()).Equals("False"))
                                {
                                    strInfo = strInfo.Replace(strAtttibute[j].ToString(), "非会员");
                                }
                                else
                                {
                                    for (int k = 0; k < vipData.Tables[0].Rows.Count; k++)
                                    {
                                        if (Lists.Rows[i]["GradeID"].ToString() == vipData.Tables[0].Rows[k]["ID"].ToString())
                                        {
                                            strInfo = strInfo.Replace(strAtttibute[j].ToString(), "<img src=\"" + Function.ProcessImageUrl(vipData.Tables[0].Rows[k]["Flag"].ToString()) + "\"/>");
                                            break;
                                        }
                                    }
                                }
                                break;
                            case "{PR:WS_GALAXIECHAT}":           //在线交流
                                string str1 = GetUserInfo(Convert.ToInt32(Lists.Rows[i]["UserID"].ToString()), "qq");
                                string str = "";
                                if (str1 != "")
                                    str = "<a target=\"blank\" href=\"http://wpa.qq.com/msgrd?V=1&Uin=" + str1 + "&Exe=QQ&Site=im.qq.com&Menu=No\"><img style=\" border:0\" src=\"{pb_weburl}images/b_online.gif\" alt=\"给我发消息\" /></a>";
                                if (HttpContext.Current.Request.Cookies["UserID"] != null && HttpContext.Current.Request.Cookies["UserID"].ToString() != "")
                                {
                                    strInfo = strInfo.Replace(strAtttibute[j].ToString(), str);
                                }
                                else
                                {
                                    strInfo = strInfo.Replace(strAtttibute[j].ToString(), "<img style=\" border:0\" src=\"{pb_weburl}images/b_online.gif\" alt=\"给我发消息\" onclick=\"javascript:alert('您还没有登陆，请先登陆')\" />");
                                }
                                break;
                            case "{PR:WS_AREA}":                  //地区
                                strInfo = strInfo.Replace(strAtttibute[j].ToString(), GetUserInfo(Convert.ToInt32(Lists.Rows[i]["UserID"].ToString()), "area"));
                                break;

                            case "{PR:WS_PRICE}":                 //价格
                                strInfo = strInfo.Replace(strAtttibute[j].ToString(), Lists.Rows[i]["Price"].ToString() + "元/" + Lists.Rows[i]["Unit"].ToString());
                                break;
                            case "{PR:WS_COMPANYNAME}":
                                if (HttpContext.Current.Request.Cookies["UserID"] != null && HttpContext.Current.Request.Cookies["UserID"].ToString() != "")
                                {
                                    strInfo = strInfo.Replace(strAtttibute[j].ToString(), GetUserInfo(Convert.ToInt32(Lists.Rows[i]["UserID"].ToString()), "companyname"));
                                }
                                else
                                {
                                    strInfo = strInfo.Replace(strAtttibute[j].ToString(), "&nbsp;");
                                }
                                break;
                            case "{PR:WS_DETAILLINK}":
                                strInfo = strInfo.Replace(strAtttibute[j].ToString(), "{PB_WEBURL}Purchase/detail-" + Lists.Rows[i]["ID"].ToString() + BasePage.Config.Rewrite);
                                break;
                            case "{PR:WS_SHOPURL}":
                                if (HttpContext.Current.Request.Cookies["UserID"] != null && HttpContext.Current.Request.Cookies["UserID"].ToString() != "")
                                {
                                    strInfo = strInfo.Replace(strAtttibute[j].ToString(), "{PB_WEBURL}Shops/index/" + GetUserInfo(Convert.ToInt32(Lists.Rows[i]["UserID"].ToString()), "LoginName") + Base.BasePage.Config.Rewrite);
                                }
                                else
                                {
                                    strInfo = strInfo.Replace(strAtttibute[j].ToString(), "#");
                                }
                                break;
                            case "{PR:WS_CHECKINFO}":
                                strInfo = strInfo.Replace(strAtttibute[j].ToString(), "<input id=\"compareBox" + i + "\" type=\"checkbox\" value=\"\" name=\" " + Lists.Rows[i]["id"].ToString() + " \" onclick=\"clickcompareBox(" + Lists.Rows[i]["id"].ToString() + ",this)\" memberId=\"stfseal\">");
                                break;
                            case "{PR:WS_QUOTATION}":
                                strInfo = strInfo.Replace(strAtttibute[j].ToString(), "{PB_WEBURL}Search/Quotation" + Base.BasePage.Config.Rewrite + "?id=" + Lists.Rows[i]["ID"].ToString());
                                break;
                        }

                    }
                    if (i > pagesize) break; //如果超过显示的条数则跳出。
                    ReBulider.Append(strInfo);
                }
            }
            ReBulider.Append("</ul>");
            ReBulider.Append("<div class=\"ltnr3 mar_top\"><p class=\"w8\"></p><p class=\"w4\"><input type=\"button\" class=\"soso\" onclick=\"doInquiry('purchase')\" value=\"批量报价\" /></p><p class=\"w6\"><input type=\"button\" class=\"qink\" onclick=\"clearCheck()\" value=\"清空全部选择\" /></p><p class=\"w7\"><a title=\"\" target=\"_blank\" class=\"l_c00_u\" href=\"{PB_WebURL}member/" + Base.BasePage.Config.Rewrite + "\">点此发布供应信息</a></p></div>");


            //求购列表尾部
            string strFooter = "";
            strFooter = Array.Footer;
            ReBulider.Append(strFooter);


            string strUrl = "{PB_WEBURL}purchase/trade" + Base.BasePage.Config.Rewrite + "?id=" + TypeID;
            if (regdate != 0)
            {
                strUrl += "&regdate=" + regdate;
            }
            if (purchaseName != "")
            {
                strUrl += "&sName=" + System.Web.HttpUtility.UrlEncode(purchaseName);
            }
            if (strOrder != 0)
            {
                strUrl += "&sOrder=" + strOrder;
            }
            if (province != "")
            {
                strUrl += "&pid=" + System.Web.HttpUtility.UrlEncode(province);
            }
            if (city != "")
            {
                strUrl += "&cid=" + System.Web.HttpUtility.UrlEncode(city);
            }
            if (area != "")
            {
                strUrl += "&aid=" + System.Web.HttpUtility.UrlEncode(area);
            }
            strUrl += "&page=";
            string Pages = Pagination.GoToPager(PageID, pagesize, strUrl, strWhere, strTabelName);
            ReBulider.Append(Pages);
            return ReBulider.ToString();
        }

        /// <summary>
        /// 处理求购分类页私有变量
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static string PR_PurchaseTrade(string Restr, string str)
        {
            // 分解传递过来的数据，取得模板内所有的私有标签
            string[] strArray;
            strArray = str.Split('|');
            string PID = "0";
            int PageIndex = 0;
            if (System.Web.HttpContext.Current.Request.QueryString["Page"] != null)
                PageIndex = Convert.ToInt32(System.Web.HttpContext.Current.Request.QueryString["Page"]);
            if (PageIndex < 1) PageIndex = 1;
            int pagecount = 0;
            if (HttpContext.Current.Request.QueryString["id"] != null && HttpContext.Current.Request.QueryString["id"] != "")
            {
                PID = HttpContext.Current.Request.QueryString["ID"];
            }
            string PurchaseName = "";
            System.Collections.Specialized.NameValueCollection nv = System.Web.HttpUtility.ParseQueryString(System.Web.HttpContext.Current.Request.Url.Query, System.Text.Encoding.GetEncoding("utf-8"));
            if (HttpContext.Current.Request.QueryString["sName"] != null)
            {
                // PurchaseName = HttpContext.Current.Request.QueryString["sName"];
                PurchaseName = System.Web.HttpUtility.UrlDecode(nv["sName"]);
            }

            int regdate = 0;
            if (Function.CheckQueryStringisInt("regdate"))
            {
                regdate = Convert.ToInt32(HttpContext.Current.Request.QueryString["regdate"]);
            }

            string province = "";
            if (HttpContext.Current.Request.QueryString["pid"] != null)
            {
                province = System.Web.HttpUtility.UrlDecode(HttpContext.Current.Request.QueryString["pid"]);
            }

            string city = "";
            if (HttpContext.Current.Request.QueryString["cid"] != null)
            {
                city = System.Web.HttpUtility.UrlDecode(HttpContext.Current.Request.QueryString["cid"]);
            }

            string area = "";
            if (HttpContext.Current.Request.QueryString["aid"] != null)
            {
                area = System.Web.HttpUtility.UrlDecode(HttpContext.Current.Request.QueryString["aid"]);
            }
            Product.TIndustryType Items = new TIndustryType();
            Items.Type = "";
            if (PID != "0")
            {
                Items = new RIndustryType().GateItem(Convert.ToInt32(PID));
            }
            try
            {
                for (int i = 0; i < strArray.Length; i++)
                {
                    switch (strArray[i].ToString().ToUpper())
                    {
                        case "{PR_PUTYPENAME}":
                            //Restr = Restr.Replace(strArray[i].ToString(), Items.Name.ToString());
                            break;
                        case "{PR_COUNT}":
                            string str1 = " C_Purchase.Verify=1 and (datediff(hh,C_Purchase.EndDate,getdate())<0)";
                            if (PID != "0")
                            {
                                str1 = "patindex('%,'+rtrim( " + PID + ")+',%',','+ IndType+',')>0 AND C_Purchase.Verify=1";
                            }

                            if (PurchaseName != "")
                            {
                                str1 += " and C_Purchase.Name like '%" + PurchaseName + "%' ";
                            }
                            if (regdate == 1) str1 += " and (DATEDIFF(year, C_Purchase.AddDate, GETDATE()) <= " + regdate + ") ";
                            else str1 += " and (DATEDIFF(year, C_Purchase.AddDate, GETDATE()) >= " + regdate + ") ";

                            if (province != "")
                            {
                                str1 += " and U_UserInfo.Province like '%" + province + "%' ";
                            }

                            if (city != "")
                            {
                                str1 += " and U_UserInfo.City like '%" + city + "%' ";
                            }

                            if (area != "")
                            {
                                str1 += " and U_UserInfo.Area like '%" + area + "%' ";
                            }
                            DataTable table = Base.PageList.GetDataTable(str1, "C_Purchase left join U_UserInfo on C_Purchase.UserID=U_UserInfo.UserID left join U_VipGrade on U_UserInfo.GradeID=U_VipGrade.ID ");
                            string count = table.Rows[0]["Total"].ToString();
                            pagecount = Int32.Parse(count);
                            Restr = Restr.Replace(strArray[i].ToString(), count);
                            break;
                        case "{PR_LOWERTYPE}":
                            Restr = Restr.Replace(strArray[i].ToString(), lowerTypeNew(Convert.ToInt32(PID), "Purchase"));
                            break;
                        case "{PR_TYPELINK}":
                            string strTypeLink = "";
                            strTypeLink = TypeLink(PID.ToString(), 0);
                            Restr = Restr.Replace(strArray[i].ToString(), strTypeLink);
                            break;
                        case "{PR_KEYWORD}":
                            Restr = Restr.Replace(strArray[i].ToString(), Items.Type);
                            break;
                        case "{PR_SELECTRES}":
                            string sName = "";
                            string spResStr = "";
                            if (System.Web.HttpContext.Current.Request.QueryString["sName"] != null)
                                sName = System.Web.HttpContext.Current.Request.QueryString["sName"];
                            if (sName != "")
                            {
                                spResStr = "符合 <font class=\"f_c00\">“" + sName + "”</font> 的查询结果";
                            }
                            Restr = Restr.Replace(strArray[i].ToString(), spResStr);
                            break;
                        case "{PR_PAGEINDEX}":
                            Restr = Restr.Replace(strArray[i].ToString(), PageIndex.ToString());
                            break;
                        case "{PR_PAGESTYLE}":
                            Restr = Restr.Replace(strArray[i].ToString(), PageIndex + "/" + (int)Math.Ceiling((double)pagecount / 10));
                            break;
                        case "{PR_PAGESTR}":
                            int pageCount = (int)Math.Ceiling((double)pagecount / 10);
                            int prevPage = PageIndex - 1;
                            int nextPage = PageIndex + 1;
                            if (prevPage < 1)
                            {
                                prevPage = 1;
                            }
                            if (nextPage > pageCount)
                            {
                                nextPage = pageCount;
                            }

                            string strUrlstr = "{PB_WEBURL}Purchase/trade" + Base.BasePage.Config.Rewrite + "?id=" + PID;
                            if (regdate != 0)
                            {
                                strUrlstr += "&regdate=" + regdate;
                            }
                            if (PurchaseName != "")
                            {
                                strUrlstr += "&sName=" + System.Web.HttpUtility.UrlEncode(PurchaseName);
                            }
                            if (System.Web.HttpContext.Current.Request.QueryString["sOrder"] != null)
                            {
                                strUrlstr += "&sOrder=" + System.Web.HttpContext.Current.Request.QueryString["sOrder"];
                            }
                            if (province != "")
                            {
                                strUrlstr += "&pid=" + System.Web.HttpUtility.UrlEncode(province);
                            }
                            if (city != "")
                            {
                                strUrlstr += "&cid=" + System.Web.HttpUtility.UrlEncode(city);
                            }
                            if (area != "")
                            {
                                strUrlstr += "&aid=" + System.Web.HttpUtility.UrlEncode(area);
                            }
                            strUrlstr += "&page=";
                            Restr = Restr.Replace(strArray[i].ToString(), "<em class=\"lt\"><a title=\"\" href=\"" + strUrlstr + prevPage + "\"></a></em><em class=\"rt\"><a title=\"\" href=\"" + strUrlstr + nextPage + "\">下一页</a></em>");
                            break;
                        case "{PR_STRORDER}":
                            int strorder = 0;
                            string txtorder = "默认排序";
                            if (System.Web.HttpContext.Current.Request.QueryString["sOrder"] != null)
                                strorder = Convert.ToInt32(System.Web.HttpContext.Current.Request.QueryString["sOrder"]);
                            switch (strorder)
                            {
                                case 1:
                                    txtorder = "<i class=\"bg1\"></i>浏览量从高到低";
                                    break;
                                case 2:
                                    txtorder = "<i class=\"bg2\"></i>浏览量从低到高";
                                    break;
                                case 3:
                                    txtorder = "<i class=\"bg5\"></i>最新发布";
                                    break;
                                case 4:
                                    txtorder = "<i class=\"bg6\"></i>最早发布";
                                    break;
                                case 0:
                                    txtorder = "<i></i>默认排序";
                                    break;
                            }

                            Restr = Restr.Replace(strArray[i].ToString(), txtorder);
                            break;
                        case "{PR_NUMORDER}":
                            int numorder = 0;
                            if (System.Web.HttpContext.Current.Request.QueryString["sOrder"] != null)
                                numorder = Convert.ToInt32(System.Web.HttpContext.Current.Request.QueryString["sOrder"]);
                            Restr = Restr.Replace(strArray[i].ToString(), numorder.ToString());
                            break;
                        case "{PR_CUR_SID}":
                            Restr = Restr.Replace(strArray[i].ToString(), PID);
                            break;
                        case "{PR_CUR_KEYWORD}":
                            Restr = Restr.Replace(strArray[i].ToString(), PurchaseName);
                            break;
                        case "{PR_CUS_REGDATE}":
                            Restr = Restr.Replace(strArray[i].ToString(), regdate.ToString());
                            break;
                        case "{PR_CUR_PID}":
                            Restr = Restr.Replace(strArray[i].ToString(), province);
                            break;
                        case "{PR_CUR_CID}":
                            Restr = Restr.Replace(strArray[i].ToString(), city);
                            break;
                        case "{PR_CUR_AID}":
                            Restr = Restr.Replace(strArray[i].ToString(), area);
                            break;
                        default:
                            break;

                    }
                }
            }
            catch (Exception e)
            {
                Restr = e.Message.ToString();
            }
            return Restr;


        }

        /// <summary>
        /// 求购首页私有变量处理方法
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static string PR_PurchaseIndex(string Restr, string str)
        {
            // 分解传递过来的数据，取得模板内所有的私有标签
            string[] strArray;
            strArray = str.Split('|');
            int PID = 0;
            PID = Convert.ToInt32(HttpContext.Current.Request.QueryString["ID"]);
            TPurchase Items = new RPurchase().GateItem(PID);
            try
            {
                for (int i = 0; i < strArray.Length; i++)
                {
                    switch (strArray[i].ToString().ToUpper())
                    {
                        case "{PR_PUTYPENAME}":
                            Restr = Restr.Replace(strArray[i].ToString(), Items.Name.ToString());
                            break;
                        case "{PR_LOWERTYPE}":
                            Restr = Restr.Replace(strArray[i].ToString(), lowerType(PID, "Purchase"));
                            break;
                        case "{PR_KEYWORD}":
                            Restr = Restr.Replace(strArray[i].ToString(), "求购信息");
                            break;
                        default:
                            break;

                    }
                }
            }
            catch (Exception e)
            {
                Restr = e.Message.ToString();
            }
            return Restr;
        }

        /// <summary>
        /// 供应首页私有变量处理方法
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static string PR_SupplyIndex(string Restr, string str)
        {
            // 分解传递过来的数据，取得模板内所有的私有标签
            string[] strArray;
            strArray = str.Split('|');
            int PID = 0;
            PID = Convert.ToInt32(HttpContext.Current.Request.QueryString["ID"]);
            TPurchase Items = new RPurchase().GateItem(PID);
            try
            {
                for (int i = 0; i < strArray.Length; i++)
                {
                    switch (strArray[i].ToString().ToUpper())
                    {
                        case "{PR_PUTYPENAME}":
                            Restr = Restr.Replace(strArray[i].ToString(), Items.Name.ToString());
                            break;
                        case "{PR_LOWERTYPE}":
                            Restr = Restr.Replace(strArray[i].ToString(), lowerType(PID, "Supply"));
                            break;
                        case "{PR_KEYWORD}":
                            Restr = Restr.Replace(strArray[i].ToString(), "供应信息");
                            break;
                        default:
                            break;

                    }
                }
            }
            catch (Exception e)
            {
                Restr = e.Message.ToString();
            }
            return Restr;
        }

        /// <summary>
        /// 供应分类页私有变量处理方法
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static string PR_SupplyTrade(string Restr, string str)
        {
            // 分解传递过来的数据，取得模板内所有的私有标签
            string[] strArray;
            strArray = str.Split('|');
            string PID = "0";
            if (Function.CheckQueryStringisInt("id"))
            {
                PID = HttpContext.Current.Request.QueryString["id"].ToString();
            }
            Product.TIndustryType Items = new TIndustryType();
            int PageIndex = 0;
            if (System.Web.HttpContext.Current.Request.QueryString["Page"] != null)
                PageIndex = Convert.ToInt32(System.Web.HttpContext.Current.Request.QueryString["Page"]);
            if (PageIndex < 1) PageIndex = 1;
            string supplyName = "";
            if (HttpContext.Current.Request.QueryString["sName"] != null)
            {
                supplyName = System.Web.HttpUtility.UrlDecode(HttpContext.Current.Request.QueryString["sName"]);
            }
            int regdate = 0;
            if (Function.CheckQueryStringisInt("regdate"))
            {
                regdate = Convert.ToInt32(HttpContext.Current.Request.QueryString["regdate"]);
            }

            string province = "";
            if (HttpContext.Current.Request.QueryString["pid"] != null)
            {
                province = System.Web.HttpUtility.UrlDecode(HttpContext.Current.Request.QueryString["pid"]);
            }

            string city = "";
            if (HttpContext.Current.Request.QueryString["cid"] != null)
            {
                city = System.Web.HttpUtility.UrlDecode(HttpContext.Current.Request.QueryString["cid"]);
            }
           
            string area = "";
            if (HttpContext.Current.Request.QueryString["aid"] != null)
            {
                area = System.Web.HttpUtility.UrlDecode(HttpContext.Current.Request.QueryString["aid"]);
            }
            
            int pagecount = 0;
            Items.Type = "";
            if (PID != "0")
            {
                Items = new RIndustryType().GateItem(Convert.ToInt32(PID));
            }
            try
            {
                for (int i = 0; i < strArray.Length; i++)
                {
                    switch (strArray[i].ToUpper())
                    {
                        case "{PR_TITLE}":
                            Restr = Restr.Replace(strArray[i].ToString(), Items.Type);
                            break;
                        case "{PR_LOWERTYPE}":
                            Restr = Restr.Replace(strArray[i].ToString(), lowerTypeNew(Convert.ToInt32(PID), "Supply"));
                            break;
                        case "{PR_COUNT}":   //供应的总数    
                            string str1 = "C_Supply.Verify=1 and (datediff(hh,C_Supply.EndDate,getdate())<0)";
                            if (!PID.Equals("0"))
                            {
                                str1 += " AND patindex('%,'+rtrim( " + PID + ")+',%',','+ IndType+',')>0 ";
                            }

                            if (supplyName != "")
                            {
                                str1 += " and C_Supply.Name like '%" + supplyName + "%' ";
                            }

                            if (regdate == 1) str1 += " and (DATEDIFF(year, C_Supply.AddDate, GETDATE()) <= " + regdate + ") ";
                            else str1 += " and (DATEDIFF(year, C_Supply.AddDate, GETDATE()) >= " + regdate + ") ";

                            if (province != "")
                            {
                                str1 += " and U_UserInfo.Province like '%" + province + "%' ";
                            }

                            if (city != "")
                            {
                                str1 += " and U_UserInfo.City like '%" + city + "%' ";
                            }

                            if (area != "")
                            {
                                str1 += " and U_UserInfo.Area like '%" + area + "%' ";
                            }

                            DataTable table = Base.PageList.GetDataTable(str1, "C_Supply left join U_UserInfo on C_Supply.UserID=U_UserInfo.UserID left join U_VipGrade on U_UserInfo.GradeID=U_VipGrade.ID ");
                            string count = table.Rows[0]["Total"].ToString();
                            pagecount = Int32.Parse(count);
                            Restr = Restr.Replace(strArray[i].ToString(), count);
                            break;
                        case "{PR_PAGESTR}":

                            int pageCount = (int)Math.Ceiling((double)pagecount / 10);
                            int prevPage = PageIndex - 1;
                            int nextPage = PageIndex + 1;
                            if (prevPage < 1)
                            {
                                prevPage = 1;
                            }
                            if (nextPage > pageCount)
                            {
                                nextPage = pageCount;
                            }

                            string strUrlstr = "{PB_WEBURL}supply/trade" + Base.BasePage.Config.Rewrite + "?id=" + PID;
                            if (regdate != 0)
                            {
                                strUrlstr += "&regdate=" + regdate;
                            }
                            if (supplyName != "")
                            {
                                strUrlstr += "&sName=" + System.Web.HttpUtility.UrlEncode(supplyName);
                            }
                            if (System.Web.HttpContext.Current.Request.QueryString["sOrder"] != null)
                            {
                                strUrlstr += "&sOrder=" + System.Web.HttpContext.Current.Request.QueryString["sOrder"];
                            }
                            if (province != "")
                            {
                                strUrlstr += "&pid=" + System.Web.HttpUtility.UrlEncode(province);
                            }
                            if (city != "")
                            {
                                strUrlstr += "&cid=" + System.Web.HttpUtility.UrlEncode(city);
                            }
                            if (area != "")
                            {
                                strUrlstr += "&aid=" + System.Web.HttpUtility.UrlEncode(area);
                            }
                            strUrlstr += "&page=";

                            Restr = Restr.Replace(strArray[i].ToString(), "<em class=\"lt\"><a title=\"\" href=\"" + strUrlstr + prevPage + "\"></a></em><em class=\"rt\"><a title=\"\" href=\"" + strUrlstr + nextPage + "\">下一页</a></em>");
                            break;
                        case "{PR_PAGESTYLE}":
                            Restr = Restr.Replace(strArray[i].ToString(), PageIndex + "/" + (int)Math.Ceiling((double)pagecount / 10));
                            break;
                        case "{PR_NUMORDER}":
                            int numorder = 0;
                            if (System.Web.HttpContext.Current.Request.QueryString["sOrder"] != null)
                                numorder = Convert.ToInt32(System.Web.HttpContext.Current.Request.QueryString["sOrder"]);
                            Restr = Restr.Replace(strArray[i].ToString(), numorder.ToString());
                            break;
                        case "{PR_STRORDER}":
                            int strorder = 0;
                            string txtorder = "默认排序";
                            if (System.Web.HttpContext.Current.Request.QueryString["sOrder"] != null)
                                strorder = Convert.ToInt32(System.Web.HttpContext.Current.Request.QueryString["sOrder"]);
                            switch (strorder)
                            {
                                case 1:
                                    txtorder = "<i class=\"bg1\"></i>浏览量从高到低";
                                    break;
                                case 2:
                                    txtorder = "<i class=\"bg2\"></i>浏览量从低到高";
                                    break;
                                case 3:
                                    txtorder = "<i class=\"bg5\"></i>最新发布";
                                    break;
                                case 4:
                                    txtorder = "<i class=\"bg6\"></i>最早发布";
                                    break;
                                case 0:
                                    txtorder = "<i></i>默认排序";
                                    break;
                            }

                            Restr = Restr.Replace(strArray[i].ToString(), txtorder);
                            break;
                        case "{PR_PAGEINDEX}":
                            Restr = Restr.Replace(strArray[i].ToString(), PageIndex.ToString());
                            break;
                        case "{PR_TYPELINK}":
                            string strTypeLink = "";
                            strTypeLink = TypeLink(PID.ToString(), 0);
                            Restr = Restr.Replace(strArray[i].ToString(), strTypeLink);
                            break;
                        case "{PR_KEYWORD}":
                            Restr = Restr.Replace(strArray[i].ToString(), Items.Type);
                            break;
                        case "{PR_SELECTRES}":
                            string sName = "";
                            string spResStr = "";
                            if (System.Web.HttpContext.Current.Request.QueryString["sName"] != null)
                                sName = System.Web.HttpContext.Current.Request.QueryString["sName"];
                            if (sName != "")
                            {
                                spResStr = "符合 <font class=\"f_c00\">“" + sName + "”</font> 的查询结果";
                            }
                            Restr = Restr.Replace(strArray[i].ToString(), spResStr);
                            break;
                        case "{PR_CUR_SID}":
                            Restr = Restr.Replace(strArray[i].ToString(), PID);
                            break;
                        case "{PR_CUR_KEYWORD}":
                            Restr = Restr.Replace(strArray[i].ToString(), supplyName);
                            break;
                        case "{PR_CUS_REGDATE}":
                            Restr = Restr.Replace(strArray[i].ToString(), regdate.ToString());
                            break;
                        case "{PR_CUR_PID}":
                            Restr = Restr.Replace(strArray[i].ToString(), province);
                            break;
                        case "{PR_CUR_CID}":
                            Restr = Restr.Replace(strArray[i].ToString(), city);
                            break;
                        case "{PR_CUR_AID}":
                            Restr = Restr.Replace(strArray[i].ToString(), area);
                            break;
                        default:
                            break;
                    }
                }
            }
            catch (Exception e)
            {
                Restr += e.Message.ToString();
            }
            return Restr;
        }

        /// <summary>
        /// 供应详细页私有变量处理方法
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static string PR_SupplyDetail(string Restr, string str)
        {
            // 分解传递过来的数据，取得模板内所有的私有标签
            string[] strArray;
            strArray = str.Split('|');
            int SID = 0;
            SID = Convert.ToInt32(HttpContext.Current.Request.QueryString["ID"]);
            TSupply Items = new RSupply().GateItem(SID);
            try
            {
                for (int i = 0; i < strArray.Length; i++)
                {
                    switch (strArray[i].ToString().ToUpper())
                    {
                        case "{PR_KEYWORD}":
                            Restr = Restr.Replace(strArray[i].ToString(), Items.Name);
                            break;
                        case "{PR_NAME}":
                            Restr = Restr.Replace(strArray[i].ToString(), Items.Name.ToString());
                            break;
                        case "{PR_MATEKEYWORD}":
                            Restr = Restr.Replace(strArray[i].ToString(), Items.Key.ToString());
                            break;
                        case "{PR_MATEDESCRIPTION}":
                            Restr = Restr.Replace(strArray[i].ToString(), Items.Name.ToString());
                            break;
                        case "{PR_TYPELINK}":                //类别列表
                            string strTypeLink = "";
                            strTypeLink = TypeLink(Items.IndType.ToString(), 1);
                            Restr = Restr.Replace(strArray[i].ToString(), strTypeLink);
                            break;
                        case "{PR_TITLE}":                   //信息名称
                            Restr = Restr.Replace(strArray[i].ToString(), Items.Name.ToString());
                            break;
                        case "{PR_PICTURE}":                 //信息图片
                            Restr = Restr.Replace(strArray[i].ToString(), Function.ProcessImageUrl(Items.Picture_1.ToString()));
                            break;
                        case "{PR_INFO}":                    //详细信息
                            Restr = Restr.Replace(strArray[i].ToString(), Items.Info.ToString());
                            break;
                        case "{PR_MODEL}":                    //详细信息
                            Restr = Restr.Replace(strArray[i].ToString(), Items.Model.ToString());
                            break;
                        case "{PR_EXPIRYDATE}":              //有效期
                            string strExpiryDate = "";
                            //strExpiryDate += Function.DateTransform(Items.StartDate.ToString(), "yyyy-mm-dd") + " - ";
                            strExpiryDate += Function.DateTransform(Items.EndDate.ToString(), "yyyy-mm-dd");
                            Restr = Restr.Replace(strArray[i].ToString(), strExpiryDate);
                            break;
                        case "{PR_COUNT}":                   //供应数量
                            Restr = Restr.Replace(strArray[i].ToString(), Items.Quantity.ToString());
                            break;
                        case "{PR_PRICE}":                   //单价
                            Restr = Restr.Replace(strArray[i].ToString(), Items.Price.ToString());
                            break;
                        case "{PR_UNIT}":                    //单位
                            Restr = Restr.Replace(strArray[i].ToString(), Items.Units.ToString());
                            break;
                        case "{PR_MINMUNUM}":                    //单位
                            Restr = Restr.Replace(strArray[i].ToString(), Items.Minimum.ToString());
                            break;
                        case "{PR_ADDDATE}":                 //发布日期
                            Restr = Restr.Replace(strArray[i].ToString(), Function.DateTransform(Items.AddDate.ToString(), "yyyy-mm-dd"));
                            break;
                        case "{PR_INTERRELATED}":            //相关供应产品
                            // Restr = Restr.Replace(strArray[i].ToString(), Purchase_Interrelated(Items.Key.ToString(), PID));
                            break;
                        case "{PR_USERGRADE}":               //会员等级
                            Restr = Restr.Replace(strArray[i].ToString(), GetUserInfo(Items.UserID, "grade"));
                            break;
                        case "{PR_COUNTYEAR}":               //第几年
                            string year = "1";
                            DateTime StartDate = DateTime.Parse(GetUserInfo(Items.UserID, "StartDate"));
                            if (((DateTime.Now.Year) - (StartDate.Year)) == 0)
                                year = "1";
                            else if (((DateTime.Now.Year) - (StartDate.Year)) > 0)
                                year = ((DateTime.Now.Year) - (StartDate.Year)).ToString();
                            Restr = Restr.Replace(strArray[i].ToString(), year);
                            break;
                        case "{PR_SAVEFAVORITES}":          //收藏信息
                            Restr = Restr.Replace(strArray[i].ToString(), systemic.PR_SaveFavorites(Items.ID.ToString(), "supply"));
                            break;
                        case "{PR_AREA}":                    //地区
                            Restr = Restr.Replace(strArray[i].ToString(), GetUserInfo(Items.UserID, "area"));
                            break;
                        case "{PR_BUSSINESSMODEL}":            //公司性质
                            Restr = Restr.Replace(strArray[i].ToString(), GetUserInfo(Items.UserID, "BusinessModel"));
                            break;
                        case "{PR_INQUIRY}":               //询价
                            Restr = Restr.Replace(strArray[i].ToString(), "{PB_WebUrl}Search/Inquiry.aspx?cpid=" + Items.ID.ToString());
                            break;
                        default:
                            break;

                    }
                }
            }
            catch (Exception e)
            {
                return Restr + e.Message.ToString();
            }
            return Restr;
        }

        /// <summary>
        ///  供应列表（仅限在求购分类页中使用）
        /// </summary>
        /// <param name="Array"></param>
        /// <returns></returns>
        public static string DIY_Supplylist(TSystemLable Array, string strModule)
        {
            // 对标签使用条件进行检查
            if (!strModule.Contains("Supply_Trade")) throw new Exception(Function.ErrInfo(2));
            string strWhere = "C_Supply.Verify=1 and (datediff(hh,C_Supply.EndDate,getdate())<0)";
            int TypeID = 0;
            if (Function.CheckQueryStringisInt("id"))
            {
                TypeID = Convert.ToInt32(HttpContext.Current.Request.QueryString["ID"]);
                strWhere += " and patindex('%,'+rtrim( " + TypeID + ")+',%',','+ IndType+',')>0 ";
            }

            string supplyName = "";
            if (HttpContext.Current.Request.QueryString["sName"] != null)
            {
                supplyName = System.Web.HttpUtility.UrlDecode(HttpContext.Current.Request.QueryString["sName"]);
            }
            if (supplyName != "")
            {
                strWhere += " and C_Supply.Name like '%" + supplyName + "%' ";
            }
            string strOrder = "";
            if (HttpContext.Current.Request.QueryString["sOrder"] != null)
            {
                strOrder = HttpContext.Current.Request.QueryString["sOrder"];
            }
            // 定义全局变量，最后返回
            StringBuilder ReBulider = new StringBuilder();

            // 求购列表头部
            string strHead = "";
            strHead = Array.Head;
            ReBulider.Append(strHead);

            string strTable = " C_Supply left join U_UserInfo on C_Supply.UserID=U_UserInfo.UserID left join U_VipGrade on U_UserInfo.GradeID=U_VipGrade.ID ";
            int OrderType = 1;
            string OrderField = " U_VipGrade.Sort desc, C_Supply.AddDate ";
            string strSelect = " C_Supply.*,U_UserInfo.UserID ,U_VipGrade.ID as VipID";

            //获得页尺寸
            int PageSize = 10;
            if (Array.Info != null)
            {
                string[] strInfo1 = Array.Info.Split('|');
                for (int k = 0; k < strInfo1.Length; k++)
                {
                    if (k == 0)
                    {
                        if (GetRequest.isNum(strInfo1[k].ToString()))
                        {
                            PageSize = Int32.Parse(strInfo1[k].ToString());
                        }
                    }
                    else if (k == 1)
                    {
                        if (GetRequest.isNum(strInfo1[k].ToString()))
                        {
                            string strType = strInfo1[k].ToString();
                            switch (strType)
                            {
                                case "0": OrderType = 0; OrderField = "  C_Supply.AddDate desc, U_VipGrade.Sort "; break;
                                case "1": OrderType = 1; OrderField = "  C_Supply.AddDate asc, U_VipGrade.Sort "; break;
                                case "2": OrderType = 1; OrderField = "  U_VipGrade.Sort desc, C_Supply.AddDate "; break;
                                case "3": OrderType = 0; OrderField = "  U_VipGrade.Sort asc, C_Supply.AddDate "; break;
                                case "4": OrderType = 1; OrderField = "  C_Supply.Price desc, C_Supply.AddDate "; break;
                                case "5": OrderType = 0; OrderField = "  C_Supply.Price asc, C_Supply.AddDate "; break;
                                case "6": OrderType = 1; OrderField = "  C_Supply.AddDate desc, C_Supply.Price "; break;
                            }
                        }
                    }
                }
            }
            int PageIndex = 0;
            if (HttpContext.Current.Request.QueryString["Page"] != null)
                PageIndex = Convert.ToInt32(HttpContext.Current.Request.QueryString["Page"]);
            if (PageIndex < 1) PageIndex = 1;
            int Count = 0;

            DataTable Lists = Pagination.GetDataTable(strWhere, strTable, OrderType, OrderField, strSelect, PageSize, PageIndex, Count, "C_Supply.ID");
            if (Lists.Rows.Count < 0)
            {
                ReBulider.Append("暂无此类产品");
            }
            else
            {
                DataSet vipData = new VipGrade.RVipGrade().GetDataTable();
                string strInfo = Array.Content.ToString();
                string[] strAtttibute = Function.GetAttribute(strInfo);
                for (int i = 0; i < Lists.Rows.Count; i++)
                {
                    strInfo = Array.Content.ToString();
                    for (int j = 0; j < strAtttibute.Length; j++)
                    {
                        switch (strAtttibute[j].ToUpper())
                        {
                            case "{PR:WS_ID}":
                                strInfo = strInfo.Replace(strAtttibute[j].ToString(), Lists.Rows[i]["ID"].ToString());
                                break;
                            case "{PR:WS_NAME}":
                                strInfo = strInfo.Replace(strAtttibute[j].ToString(), Lists.Rows[i]["Name"].ToString());
                                break;
                            case "{PR:WS_PICTURE}":
                                strInfo = strInfo.Replace(strAtttibute[j].ToString(), Function.ProcessImageUrl(Lists.Rows[i]["Thumbnail"].ToString()));
                                break;
                            case "{PR:WS_ADDDATE}":
                                strInfo = strInfo.Replace(strAtttibute[j].ToString(), DateTime.Parse(Lists.Rows[i]["AddDate"].ToString()).ToShortDateString());
                                break;
                            case "{PR:WS_INFO}":
                                strInfo = strInfo.Replace(strAtttibute[j].ToString(), Function.GetString(Base.Common.RemoveHTML(Lists.Rows[i]["Info"].ToString()), 40));
                                break;
                            case "{PR:WS_PRICE}":
                                strInfo = strInfo.Replace(strAtttibute[j].ToString(), Lists.Rows[i]["Price"].ToString() + "元/" + Lists.Rows[i]["Units"].ToString());
                                break;
                            case "{PR:WS_LEVEL}":
                                for (int k = 0; k < vipData.Tables[0].Rows.Count; k++)
                                {
                                    if (Lists.Rows[i]["VipID"].ToString() == vipData.Tables[0].Rows[k]["ID"].ToString())
                                    {
                                        strInfo = strInfo.Replace(strAtttibute[j].ToString(), "<img src=\"" + Function.ProcessImageUrl(vipData.Tables[0].Rows[k]["Flag"].ToString()) + "\"/>");
                                        break;
                                    }
                                }
                                break;
                            case "{PR:WS_BRAND}":
                                strInfo = strInfo.Replace(strAtttibute[j].ToString(), Lists.Rows[i]["brand"].ToString());
                                break;
                            case "{PR:WS_PLACE}":                       //地区
                                strInfo = strInfo.Replace(strAtttibute[j].ToString(), GetUserInfo(Convert.ToInt32(Lists.Rows[i]["UserID"].ToString()), "area"));
                                break;
                            case "{PR:WS_COMPANYNAME}":
                                strInfo = strInfo.Replace(strAtttibute[j].ToString(), GetUserInfo(Convert.ToInt32(Lists.Rows[i]["UserID"].ToString()), "companyname"));
                                break;
                            case "{PR:WS_CONTACTWAY}":                //联系我们
                                string strWay = "<a href='{Pb_webUrl}shops/Contact/" + GetUserInfo(Convert.ToInt32(Lists.Rows[i]["UserID"].ToString()), "loginName") + BasePage.Config.Rewrite + "'>联系方式</a>";
                                strInfo = strInfo.Replace(strAtttibute[j].ToString(), strWay);
                                break;
                            case "{PR:WS_INQUIRY}":                   //询价
                                strInfo = strInfo.Replace(strAtttibute[j].ToString(), "{PB_WebUrl}Search/Inquiry.aspx?type=supply&cpid=" + Lists.Rows[i]["ID"].ToString());
                                break;
                            case "{PR:WS_DETAILLINK}":               //详细链接
                                strInfo = strInfo.Replace(strAtttibute[j].ToString(), "{PB_WebUrl}Supply/Detail-" + Lists.Rows[i]["ID"].ToString() + BasePage.Config.Rewrite);
                                break;
                            case "{PR:WS_COMPANYLINK}":               //详细链接
                                string UID = Lists.Rows[i]["UserID"].ToString();
                                TUserInfo tsuser = new RUserInfo().GateItem(int.Parse(UID));
                                strInfo = strInfo.Replace(strAtttibute[j].ToString(), "{PB_WebUrl}Shops/index/" + tsuser.LoginName + BasePage.Config.Rewrite);
                                break;
                            case "{PR:WS_GALAXIECHAT}":              //在线交流
                                string str1 = GetUserInfo(Convert.ToInt32(Lists.Rows[i]["UserID"].ToString()), "qq");
                                string str = "";
                                if (str1 != "")
                                    str = "<a target=\"blank\" href=\"http://wpa.qq.com/msgrd?V=1&Uin=" + str1 + "&Exe=QQ&Site=im.qq.com&Menu=No\"><img style=\" border:0\" src=\"{pb_weburl}images/b_online.gif\" alt=\"给我发消息\" /></a>";
                                strInfo = strInfo.Replace(strAtttibute[j].ToString(), str);
                                break;
                            case "{PR:WS_SHOPURL}":
                                strInfo = strInfo.Replace(strAtttibute[j].ToString(), "{PB_WEBURL}Shop/index/" + GetUserInfo(Convert.ToInt32(Lists.Rows[i]["UserID"].ToString()), "loginName") + Base.BasePage.Config.Rewrite);
                                break;
                            case "{PR:WS_CHECKINFO}":
                                strInfo = strInfo.Replace(strAtttibute[j].ToString(), "<input id=\"compareBox" + i + "\" type=\"checkbox\" value=\"\" name=\" " + Lists.Rows[i]["id"].ToString() + " \" onclick=\"clickcompareBox(" + Lists.Rows[i]["id"].ToString() + ",this)\" memberId=\"stfseal\">");
                                break;
                        }
                    }
                    ReBulider.Append(strInfo);
                    ReBulider.Append(System.Environment.NewLine);
                }
            }
            ReBulider.Append("</ul>");
            ReBulider.Append("<div class=\"ltnr3 mar_top\"><p class=\"w8\"></p><p class=\"w4\"><input type=\"button\" class=\"soso\" onclick=\"doInquiry('Supply')\" value=\"批量询价\" /></p><p class=\"w6\"><input type=\"button\" class=\"qink\" onclick=\"clearCheck()\" value=\"清空全部选择\" /></p><p class=\"w7\">没我想要的，<a title=\"\" target=\"_blank\" class=\"l_c00_u\" href=\"{PB_WebUrl}member/index.aspx\">点此发布求购信息</a>，让供应商来找我！</p></div>");
            //求购列表尾部
            string strFooter = "";
            strFooter = Array.Footer;
            ReBulider.Append(strFooter);

            string strUrl = "Trade";
            if (TypeID != 0)
            {
                strUrl += "-" + TypeID;
            }
            if (supplyName != "")
            {
                strUrl += "-n" + supplyName;
            }
            strUrl += "-p";
            string Pages = Pagination.GoToPager(PageIndex, PageSize, strUrl, strWhere, strTable);
            ReBulider.Append(Pages);
            return ReBulider.ToString();
        }

        /// <summary>
        ///  供应列表（仅限在供应信息搜索及类别列表页中使用）
        /// </summary>
        /// <param name="Array"></param>
        /// <returns></returns>
        public static string DIY_Supplylist_Search(TSystemLable Array, string strModule)
        {
            // 对标签使用条件进行检查
            if (!strModule.Contains("Supply_Trade")) throw new Exception(Function.ErrInfo(2));
            string strWhere = "C_Supply.Verify=1 and (datediff(hh,C_Supply.EndDate,getdate())<0)";
            int TypeID = 0;
            if (Function.CheckQueryStringisInt("id"))
            {
                TypeID = Convert.ToInt32(HttpContext.Current.Request.QueryString["ID"]);
                strWhere += " and patindex('%,'+rtrim( " + TypeID + ")+',%',','+ IndType+',')>0 ";
            }

            string supplyName = "";
            if (HttpContext.Current.Request.QueryString["sName"] != null)
            {
                supplyName = System.Web.HttpUtility.UrlDecode(HttpContext.Current.Request.QueryString["sName"]);
            }
            if (supplyName != "")
            {
                strWhere += " and C_Supply.Name like '%" + supplyName + "%' ";
            }

            int regdate = 0;
            if (Function.CheckQueryStringisInt("regdate"))
            {
                regdate = Convert.ToInt32(HttpContext.Current.Request.QueryString["regdate"]);
                if (regdate == 1) strWhere += " and (DATEDIFF(year, C_Supply.AddDate, GETDATE()) <= " + regdate + ") ";
                else strWhere += " and (DATEDIFF(year, C_Supply.AddDate, GETDATE()) >= " + regdate + ") ";
            }

            string province = "";
            if (HttpContext.Current.Request.QueryString["pid"] != null)
            {
                province = System.Web.HttpUtility.UrlDecode(HttpContext.Current.Request.QueryString["pid"]);
            }
            if (province != "")
            {
                strWhere += " and U_UserInfo.Province like '%" + province + "%' ";
            }

            string city = "";
            if (HttpContext.Current.Request.QueryString["cid"] != null)
            {
                city = System.Web.HttpUtility.UrlDecode(HttpContext.Current.Request.QueryString["cid"]);
            }
            if (city != "")
            {
                strWhere += " and U_UserInfo.City like '%" + city + "%' ";
            }

            string area = "";
            if (HttpContext.Current.Request.QueryString["aid"] != null)
            {
                area = System.Web.HttpUtility.UrlDecode(HttpContext.Current.Request.QueryString["aid"]);
            }
            if (area != "")
            {
                strWhere += " and U_UserInfo.Area like '%" + area + "%' ";
            }

            int strOrder = 0;
            int OrderType = 1;
            string OrderField = " U_VipGrade.Sort desc, C_Supply.AddDate ";
            if (HttpContext.Current.Request.QueryString["sOrder"] != null)
            {
                strOrder = Convert.ToInt32(HttpContext.Current.Request.QueryString["sOrder"]);
                switch (strOrder)
                {
                    case 1:
                        OrderType = 1;
                        OrderField = " U_VipGrade.Sort desc, C_Supply.Price ";
                        break;
                    case 2:
                        OrderType = 0;
                        OrderField = " U_VipGrade.Sort desc, C_Supply.Price ";
                        break;
                    case 3:
                        OrderType = 1;
                        OrderField = " U_VipGrade.Sort desc, C_Supply.AddDate ";
                        break;
                    case 4:
                        OrderType = 0;
                        OrderField = " U_VipGrade.Sort desc, C_Supply.AddDate ";
                        break;
                }
            }
            // 定义全局变量，最后返回
            StringBuilder ReBulider = new StringBuilder();

            // 求购列表头部
            string strHead = "";
            strHead = Array.Head;
            ReBulider.Append(strHead);

            string strTable = " C_Supply left join U_UserInfo on C_Supply.UserID=U_UserInfo.UserID left join U_VipGrade on U_UserInfo.GradeID=U_VipGrade.ID ";
            string strSelect = " C_Supply.*,U_UserInfo.UserID ,U_VipGrade.ID as VipID";

            //获得页尺寸
            int PageSize = 10;
            if (Array.Info != null)
            {
                string[] strInfo1 = Array.Info.Split('|');
                for (int k = 0; k < strInfo1.Length; k++)
                {
                    if (k == 0)
                    {
                        if (GetRequest.isNum(strInfo1[k].ToString()))
                        {
                            PageSize = Int32.Parse(strInfo1[k].ToString());
                            break;
                        }
                    }
                }
            }
            int PageIndex = 0;
            if (HttpContext.Current.Request.QueryString["Page"] != null)
                PageIndex = Convert.ToInt32(HttpContext.Current.Request.QueryString["Page"]);
            if (PageIndex < 1) PageIndex = 1;
            int Count = 0;

            DataTable Lists = Pagination.GetDataTable(strWhere, strTable, OrderType, OrderField, strSelect, PageSize, PageIndex, Count, "C_Supply.ID");
            if (Lists.Rows.Count < 0)
            {
                ReBulider.Append("暂无此类产品");
            }
            else
            {
                DataSet vipData = new VipGrade.RVipGrade().GetDataTable();
                string strInfo = Array.Content.ToString();
                string[] strAtttibute = Function.GetAttribute(strInfo);
                for (int i = 0; i < Lists.Rows.Count; i++)
                {
                    strInfo = Array.Content.ToString();
                    for (int j = 0; j < strAtttibute.Length; j++)
                    {
                        switch (strAtttibute[j].ToUpper())
                        {
                            case "{PR:WS_ID}":
                                strInfo = strInfo.Replace(strAtttibute[j].ToString(), Lists.Rows[i]["ID"].ToString());
                                break;
                            case "{PR:WS_NAME}":
                                strInfo = strInfo.Replace(strAtttibute[j].ToString(), Lists.Rows[i]["Name"].ToString());
                                break;
                            case "{PR:WS_PICTURE}":
                                strInfo = strInfo.Replace(strAtttibute[j].ToString(), Function.ProcessImageUrl(Lists.Rows[i]["Thumbnail"].ToString()));
                                break;
                            case "{PR:WS_ADDDATE}":
                                strInfo = strInfo.Replace(strAtttibute[j].ToString(), DateTime.Parse(Lists.Rows[i]["AddDate"].ToString()).ToShortDateString());
                                break;
                            case "{PR:WS_INFO}":
                                strInfo = strInfo.Replace(strAtttibute[j].ToString(), Function.GetString(Base.Common.RemoveHTML(Lists.Rows[i]["Info"].ToString()), 40));
                                break;
                            case "{PR:WS_PRICE}":
                                strInfo = strInfo.Replace(strAtttibute[j].ToString(), Lists.Rows[i]["Price"].ToString() + "元/" + Lists.Rows[i]["Units"].ToString());
                                break;
                            case "{PR:WS_LEVEL}":
                                for (int k = 0; k < vipData.Tables[0].Rows.Count; k++)
                                {
                                    if (Lists.Rows[i]["VipID"].ToString() == vipData.Tables[0].Rows[k]["ID"].ToString())
                                    {
                                        strInfo = strInfo.Replace(strAtttibute[j].ToString(), "<img src=\"" + Function.ProcessImageUrl(vipData.Tables[0].Rows[k]["Flag"].ToString()) + "\"/>");
                                        break;
                                    }
                                }
                                break;
                            case "{PR:WS_BRAND}":
                                strInfo = strInfo.Replace(strAtttibute[j].ToString(), Lists.Rows[i]["brand"].ToString());
                                break;
                            case "{PR:WS_PLACE}":                       //地区
                                strInfo = strInfo.Replace(strAtttibute[j].ToString(), GetUserInfo(Convert.ToInt32(Lists.Rows[i]["UserID"].ToString()), "area"));
                                break;
                            case "{PR:WS_COMPANYNAME}":
                                strInfo = strInfo.Replace(strAtttibute[j].ToString(), GetUserInfo(Convert.ToInt32(Lists.Rows[i]["UserID"].ToString()), "companyname"));
                                break;
                            case "{PR:WS_CONTACTWAY}":                //联系我们
                                string strWay = "<a href='{Pb_webUrl}shops/Contact/" + GetUserInfo(Convert.ToInt32(Lists.Rows[i]["UserID"].ToString()), "loginName") + BasePage.Config.Rewrite + "'>联系方式</a>";
                                strInfo = strInfo.Replace(strAtttibute[j].ToString(), strWay);
                                break;
                            case "{PR:WS_INQUIRY}":                   //询价
                                strInfo = strInfo.Replace(strAtttibute[j].ToString(), "{PB_WebUrl}Search/Inquiry.aspx?type=supply&cpid=" + Lists.Rows[i]["ID"].ToString());
                                break;
                            case "{PR:WS_DETAILLINK}":               //详细链接
                                strInfo = strInfo.Replace(strAtttibute[j].ToString(), "{PB_WebUrl}Supply/Detail-" + Lists.Rows[i]["ID"].ToString() + BasePage.Config.Rewrite);
                                break;
                            case "{PR:WS_COMPANYLINK}":               //详细链接
                                string UID = Lists.Rows[i]["UserID"].ToString();
                                TUserInfo tsuser = new RUserInfo().GateItem(int.Parse(UID));
                                strInfo = strInfo.Replace(strAtttibute[j].ToString(), "{PB_WebUrl}Shops/index/" + tsuser.LoginName + BasePage.Config.Rewrite);
                                break;
                            case "{PR:WS_GALAXIECHAT}":              //在线交流
                                string str1 = GetUserInfo(Convert.ToInt32(Lists.Rows[i]["UserID"].ToString()), "qq");
                                string str = "";
                                if (str1 != "")
                                    str = "<a target=\"blank\" href=\"http://wpa.qq.com/msgrd?V=1&Uin=" + str1 + "&Exe=QQ&Site=im.qq.com&Menu=No\"><img style=\" border:0\" src=\"{pb_weburl}images/b_online.gif\" alt=\"给我发消息\" /></a>";
                                strInfo = strInfo.Replace(strAtttibute[j].ToString(), str);
                                break;
                            case "{PR:WS_SHOPURL}":
                                strInfo = strInfo.Replace(strAtttibute[j].ToString(), "{PB_WEBURL}Shop/index/" + GetUserInfo(Convert.ToInt32(Lists.Rows[i]["UserID"].ToString()), "loginName") + Base.BasePage.Config.Rewrite);
                                break;
                            case "{PR:WS_CHECKINFO}":
                                strInfo = strInfo.Replace(strAtttibute[j].ToString(), "<input id=\"compareBox" + i + "\" type=\"checkbox\" value=\"\" name=\" " + Lists.Rows[i]["id"].ToString() + " \" onclick=\"clickcompareBox(" + Lists.Rows[i]["id"].ToString() + ",this)\" memberId=\"stfseal\">");
                                break;
                        }
                    }
                    ReBulider.Append(strInfo);
                    ReBulider.Append(System.Environment.NewLine);
                }
            }
            ReBulider.Append("</ul>");
            ReBulider.Append("<div class=\"ltnr3 mar_top\"><p class=\"w8\"></p><p class=\"w4\"><input type=\"button\" class=\"soso\" onclick=\"doInquiry('Supply')\" value=\"批量询价\" /></p><p class=\"w6\"><input type=\"button\" class=\"qink\" onclick=\"clearCheck()\" value=\"清空全部选择\" /></p><p class=\"w7\">没我想要的，<a title=\"\" target=\"_blank\" class=\"l_c00_u\" href=\"{PB_WebUrl}member/index.aspx\">点此发布求购信息</a>，让供应商来找我！</p></div>");
            //求购列表尾部
            string strFooter = "";
            strFooter = Array.Footer;
            ReBulider.Append(strFooter);

            string strUrl = "{PB_WEBURL}supply/trade" + Base.BasePage.Config.Rewrite + "?id=" + TypeID;
            if (regdate != 0)
            {
                strUrl += "&regdate=" + regdate;
            }
            if (supplyName != "")
            {
                strUrl += "&sName=" + System.Web.HttpUtility.UrlEncode(supplyName);
            }
            if (strOrder != 0)
            {
                strUrl += "&sOrder=" + strOrder;
            }
            if (province != "")
            {
                strUrl += "&pid=" + System.Web.HttpUtility.UrlEncode(province);
            }
            if (city != "")
            {
                strUrl += "&cid=" + System.Web.HttpUtility.UrlEncode(city);
            }
            if (area != "")
            {
                strUrl += "&aid=" + System.Web.HttpUtility.UrlEncode(area);
            }
            strUrl += "&page=";
            string Pages = Pagination.GoToPager(PageIndex, PageSize, strUrl, strWhere, strTable);
            ReBulider.Append(Pages);
            return ReBulider.ToString();
        }

        private static string GetVipGrade(int GradeID)
        {
            SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["sqldata"].ConnectionString);
            SqlCommand cmd = new SqlCommand("SELECT [Flag] FROM [U_VipGrade] WHERE ID=@ID", con);
            cmd.Parameters.AddWithValue("@ID", GradeID);
            con.Open();
            SqlDataReader sr = cmd.ExecuteReader();
            if (sr.Read())
            {
                return sr["Flag"].ToString();
            }
            con.Close();
            return "";
        }

        /// <summary>
        /// 公司最新产品
        /// </summary>
        /// <param name="Array">
        /// Num	          显示条数      
        /// RowsNum	      每行显示几条
        /// WhichType     [0：供应,1：求购]
        /// PicWidth      图宽
        /// PicHeight     图高
        /// PicClass      图Class
        /// TitleSize	  标题字数	
        /// TitleClass    标题样式
        /// Target	      打开方式 [_blank ,_self]
        /// strAttribute  [0：全部，1：当前频道]
        /// Recommend     [0:不推荐，1：推荐]  
        /// </param>
        /// <returns></returns> 
        public static string SY_DetailNewProduct(TSystemLable Array)
        {
            // 分解的参数信息
            string[] strContent;
            strContent = Array.Info.Split(new char[] { '|' });

            //初始化参数,如果参数不够则跳出
            if (strContent.Length != 11) return Function.ErrInfo(0);

            int Num = 0;
            int RowsNum = 0;
            int PicWidth = 0;
            int PicHight = 0;
            int TitleSize = 0;
            if (strContent[0].ToString().Trim() != "") Num = Convert.ToInt32(strContent[0].ToString());
            if (strContent[1].ToString().Trim() != "") RowsNum = Convert.ToInt32(strContent[1].ToString());
            string WhichType = strContent[2].ToString();
            if (strContent[3].ToString().Trim() != "") PicWidth = Convert.ToInt32(strContent[3].ToString());
            if (strContent[4].ToString().Trim() != "") PicHight = Convert.ToInt32(strContent[4].ToString());
            string PicClass = strContent[5].ToString();
            if (strContent[6].ToString().Trim() != "") TitleSize = Convert.ToInt32(strContent[6].ToString());
            string TitleClass = strContent[7].ToString();
            string Target = strContent[8].ToString();
            string strAttribute = strContent[9].ToString();
            string Recommend = strContent[10].ToString();
            //获取该产品的其他信息
            int PID = 0;
            PID = Convert.ToInt32(HttpContext.Current.Request.QueryString["ID"]);
            DataTable ProductList = new DataTable();
            if (WhichType == "0")
            {
                TSupply Items = new RSupply().GateItem(PID);
                ProductList = GetDt(Items, 0, Num, strAttribute, Recommend);
            }
            else
            {
                TPurchase Items = new RPurchase().GateItem(PID);
                ProductList = GetDt(Items, 1, Num, strAttribute, Recommend);
            }
            StringBuilder strBuilder = new StringBuilder();
            if (ProductList.Rows.Count <= 0) return "没有相关产品";
            strBuilder.Append("<div class=\"sps2cot\"><ul class=\"sps2c\">");
            for (int i = 0; i < ProductList.Rows.Count; i++)
            {
               // if (i > Num - 1) break; //如果超过显示的条数则跳出。

                strBuilder.Append("<li><p class=\"tu\">");
                strBuilder.Append("<a title=\"\" href=\"{PB_WEBURL}Supply/detail-" + ProductList.Rows[i]["ID"].ToString() + BasePage.Config.Rewrite + "\"><img alt=\"\" src=\"" + Function.ProcessImageUrl(ProductList.Rows[i]["Thumbnail"].ToString()) + "\" /></a>");
                strBuilder.Append("</p>");
                strBuilder.Append("<p class=\"zi\"><a title=\"\" href=\"{PB_WEBURL}Supply/detail-" + ProductList.Rows[i]["ID"].ToString() + BasePage.Config.Rewrite + "\">" + Function.GetString(ProductList.Rows[i]["Name"].ToString(), TitleSize) + "</a></p>");
                strBuilder.Append("</li>");
            }
            strBuilder.Append(@"</ul></div> ");
            return strBuilder.ToString();
        }

        private static DataTable GetDt(TSupply Items, int Type, int Num, string strAttribute, string Recommend)
        {
            string strSelect = "";
            if (Num <= 0)
                strSelect += "top 1 ";
            else
                strSelect += " top " + Num;

            strSelect += " ID,Thumbnail,Name";
            string strWhere = " where UserID=" + Items.UserID;
            if (strAttribute == "1")
                strWhere += " and IndType='" + Items.IndType.ToString() + "'";
            if (Recommend == "1")
                strWhere += " and UserRecommend=1";

            string strOrder = " order by AddDate desc ";
            string strTableName = " C_Supply";

            //获取数据表
            DataTable ProductList = Function.GetDataTable(strSelect, strWhere, strTableName, strOrder);
            return ProductList;
        }

        private static DataTable GetDt(TPurchase Items, int Type, int Num, string strAttribute, string Recommend)
        {
            string strSelect = "";
            if (Num <= 0)
                strSelect += "top 1 ";
            else
                strSelect += " top " + Num;

            strSelect += " ID,Thumbnail,Name";
            string strWhere = " where UserID=" + Items.UserID;
            if (strAttribute == "1")
                strWhere += " and IndType='" + Items.IndType.ToString() + "'";
            if (Recommend == "1")
                strWhere += " and UserRecommend=1";

            string strOrder = " order by AddDate desc ";
            string strTableName = "C_Purchase";

            //获取数据表
            DataTable ProductList = Function.GetDataTable(strSelect, strWhere, strTableName, strOrder);
            return ProductList;
        }

        public static string DIY_SupplyInfo(TSystemLable Array)
        {
            int SID = 0;
            // 判断是否出错
            //if (StrModule != "Supply_detail") goto Err0;
            int intID = Convert.ToInt32(HttpContext.Current.Request.QueryString["id"]);
            //int intID =100006 ;
            if (intID <= 0) goto Err1;

            TSupply strInfo = new RSupply().GateItem(intID);
            if (strInfo.ID <= 0)
            {
                return "该供应信息不存在！";
            }
            string strContent = Array.Content.ToString();  //取得用户自定义的标签内容
            string[] strAtttibute = Function.GetAttribute(strContent);
            if (strAtttibute.Length != 0)
            {
                for (int i = 0; i < strAtttibute.Length; i++)
                {
                    TUserInfo t = new RUserInfo().GateItem(strInfo.UserID);
                    switch (strAtttibute[i].ToUpper())
                    {
                        case "{PR:WS_PRICE}":              //产品价格
                            strContent = strContent.Replace(strAtttibute[i].ToString(), strInfo.Price.ToString() + "元/" + strInfo.Units.ToString());
                            break;
                        case "{PR:WS_IMAGE}":              //产品图片
                            strContent = strContent.Replace(strAtttibute[i].ToString(), Function.ProcessImageUrl(strInfo.Thumbnail));
                            break;
                        case "{PR:WS_IMGBIG}":
                            strContent = strContent.Replace(strAtttibute[i].ToString(), strInfo.Thumbnail.Replace("t_","m_")); break;
                        case "{PR:WS_MINAMOUNT}":          //最小起订
                            strContent = strContent.Replace(strAtttibute[i].ToString(), strInfo.Minimum.ToString() + " " + strInfo.Units.ToString());
                            break;
                        case "{PR:WS_MAXAMOUNT}":          //供货数量
                            strContent = strContent.Replace(strAtttibute[i].ToString(), strInfo.Quantity.ToString() + " " + strInfo.Units.ToString());
                            break;
                        case "{PR:WS_ADDRESS}":            //所在地
                            strContent = strContent.Replace(strAtttibute[i].ToString(), strInfo.Place.ToString());
                            break;
                        case "{PR:WS_LINKMAN}":            //联系人
                            
                            strContent = strContent.Replace(strAtttibute[i].ToString(), t.LinkName + " " + t.Sex.ToString());
                            break;
                        case "{PR:WS_FAX}":                //有效期
                            strContent = strContent.Replace(strAtttibute[i].ToString(), strInfo.EndDate.ToShortDateString());
                            break;
                        case "{PR:WS_LOGO}":               //品牌
                            strContent = strContent.Replace(strAtttibute[i].ToString(), strInfo.Brand.ToString());
                            break;
                        case "{PR:WS_TYPE}":               //规格型号
                            strContent = strContent.Replace(strAtttibute[i].ToString(), strInfo.Model.ToString());
                            break;
                        case "{PR:WS_DESCRIPTION}":        //详细信息
                            strContent = strContent.Replace(strAtttibute[i].ToString(), strInfo.Info.ToString());
                            break;
                        case "{PR:WS_ALLINFO}":            //详细信息
                            strContent = strContent.Replace(strAtttibute[i].ToString(), strInfo.Document.ToString());
                            break;
                        case "{PR:WS_SAVEFAVORITES}":        //收藏信息
                            strContent = strContent.Replace(strAtttibute[i].ToString(), systemic.PR_SaveFavorites(strInfo.ID.ToString(), "supply"));
                            break;
                        case "{PR:WS_QUOTATION}":        //点此询价
                            strContent = strContent.Replace(strAtttibute[i].ToString(), "{PB_WebUrl}/Search/Inquiry.aspx?type=supply&cpid=" + strInfo.ID.ToString());
                            break;
                        case "{PR:WS_PNAME}":        //产品名称
                            strContent = strContent.Replace(strAtttibute[i].ToString(), strInfo.Name.ToString());
                            break;
                        case "{PR:WS_GALAXIECHAT}":              //在线交流
                            string str1 = t.QQ;
                            string str = "";
                            if (str1 != "")
                            {
                                str = "<a target=\"blank\" href=\"http://wpa.qq.com/msgrd?V=1&Uin=" + str1 + "&Exe=QQ&Site=im.qq.com&Menu=No\"><img style=\" border:0\" src=\"{pb_weburl}images/zxqt.gif\" alt=\"给我发消息\" /></a>";
                            }
                            strContent = strContent.Replace(strAtttibute[i].ToString(), str);
                            break;
                        case "{PR:WS_COMPLOGO}": //公司logo
                            string comlogo = t.Logo;
                            strContent = strContent.Replace(strAtttibute[i].ToString(), "<img alt=\"\" src=\"" + comlogo + "\" />");
                            break;
                    }
                }
            }
            return strContent;
        Err1:
            return Function.ErrInfo(1);
        }

        public static string DIY_ProductInfo(TSystemLable Array)
        {
            int SID = 0;
            // 判断是否出错
            //if (StrModule != "Supply_detail") goto Err0;
            int intID = Convert.ToInt32(HttpContext.Current.Request.QueryString["id"]);
            //int intID =100006 ;
            if (intID <= 0) goto Err1;

            TPurchase strInfo = new RPurchase().GateItem(intID);
            if (strInfo.ID <= 0)
            {
                return "该求购信息不存在！";
            }
            string strContent = Array.Content.ToString();  //取得用户自定义的标签内容
            string[] strAtttibute = Function.GetAttribute(strContent);
            if (strAtttibute.Length != 0)
            {
                for (int i = 0; i < strAtttibute.Length; i++)
                {
                    TUserInfo t = new RUserInfo().GateItem(strInfo.UserID);
                    switch (strAtttibute[i].ToUpper())
                    {
                        case "{PR:WS_COMPANYNAME}":         //公司名称
                            if (strInfo.IsUser.Equals("True"))
                            {
                                strContent = strContent.Replace(strAtttibute[i].ToString(), t.CompanyName);
                            }
                            else if (strInfo.IsUser.Equals("False"))
                            {
                                string CompanyName = GetVisitorComPanyName(strInfo.UserID);
                                strContent = strContent.Replace(strAtttibute[i].ToString(), CompanyName + " (非会员)");
                            }
                            break;
                        case "{PR:WS_BUSINESSMODE}":        //经营模式
                            if (strInfo.IsUser.Equals("True"))
                            {
                                
                                string[] strc;
                                string temp = "";
                                strc = (t.BusinessModel.ToString()).Split(new char[] { ',' });
                                foreach (string var in strc)
                                {
                                    if (var.Equals("0"))
                                    {
                                        temp += "生产型 |";
                                    }
                                    if (var.Equals("1"))
                                    {
                                        temp += " 贸易型 |";
                                    }
                                    if (var.Equals("2"))
                                    {
                                        temp += " 服务型 |";
                                    }
                                    if (var.Equals("3"))
                                    {
                                        temp += " 政府或其他机构 ";
                                    }
                                }
                                strContent = strContent.Replace(strAtttibute[i].ToString(), temp);
                            }
                            else if (strInfo.IsUser.Equals("False"))
                            {
                                string CompanyName = GetVisitorComPanyName(strInfo.UserID);
                                strContent = strContent.Replace(strAtttibute[i].ToString(), " (非会员)");
                            }
                            break;
                        case "{PR:WS_ADDRESS}":             //所在地
                            if (strInfo.IsUser.Equals("True"))
                            {
                                strContent = strContent.Replace(strAtttibute[i].ToString(), t.Province + " " + t.City);
                            }
                            else if (strInfo.IsUser.Equals("False"))
                            {
                                strContent = strContent.Replace(strAtttibute[i].ToString(), " (非会员)");
                            }
                            break;
                        case "{PR:WS_ADDDATE}":            //发布时间                           
                            strContent = strContent.Replace(strAtttibute[i].ToString(), strInfo.AddDate.ToShortDateString());
                            break;
                        case "{PR:WS_ENDDATE}":               //到期时间
                            strContent = strContent.Replace(strAtttibute[i].ToString(), strInfo.EndDate.ToShortDateString());
                            break;
                        case "{PR:WS_LOGO}":               //品牌
                            strContent = strContent.Replace(strAtttibute[i].ToString(), strInfo.Brand.ToString());
                            break;
                        case "{PR:WS_TYPE}":               //规格型号
                            strContent = strContent.Replace(strAtttibute[i].ToString(), strInfo.Model);
                            break;
                        case "{PR:WS_DESCRIPTION}":        //详细信息
                            strContent = strContent.Replace(strAtttibute[i].ToString(), strInfo.Info);
                            break;
                        case "{PR:WS_SAVEFAVORITES}":        //收藏信息
                            strContent = strContent.Replace(strAtttibute[i].ToString(), systemic.PR_SaveFavorites(strInfo.ID.ToString(), "purchase"));

                            break;
                        case "{PR:WS_QUOTATION}":        //点此报价
                            strContent = strContent.Replace(strAtttibute[i].ToString(), "{PB_WebUrl}Search/Quotation.aspx?id=" + strInfo.ID.ToString());
                            break;
                        case "{PR:WS_IMAGE}":              //产品图片
                            strContent = strContent.Replace(strAtttibute[i].ToString(), Function.ProcessImageUrl(strInfo.Thumbnail));
                            break;
                        case "{PR:WS_GALAXIECHAT}":              //在线交流
                            string str1 = t.QQ;
                            string str = "";
                            if (str1 != "")
                            {
                                str = "<a target=\"blank\" href=\"http://wpa.qq.com/msgrd?V=1&Uin=" + str1 + "&Exe=QQ&Site=im.qq.com&Menu=No\"><img style=\" border:0\" src=\"{pb_weburl}images/zxqt.gif\" alt=\"给我发消息\" /></a>";
                            }
                            strContent = strContent.Replace(strAtttibute[i].ToString(), str);
                            break;
                    }
                }
            }
            return strContent;
        Err1:
            return Function.ErrInfo(1);
        }

        public static string GetVisitorComPanyName(int ID)
        {
            SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["sqlData"].ConnectionString);
            SqlCommand cmd = new SqlCommand("SELECT CompanyName FROM [U_Visitor] WHERE ID=@ID", con);
            cmd.Parameters.AddWithValue("@ID", ID);
            con.Open();
            SqlDataReader sr = cmd.ExecuteReader();
            if (sr.Read())
            {
                return sr["CompanyName"].ToString();
            }
            con.Close();
            return "";
        }

    }
}